Quellcode durchsuchen

Use real path of all files internally, requires _XOPEN_SOURCE>=500, fixes issue #137

master
Bert Münnich vor 10 Jahren
Ursprung
Commit
6d7acac3d1
2 geänderte Dateien mit 22 neuen und 9 gelöschten Zeilen
  1. +7
    -6
      Makefile
  2. +15
    -3
      main.c

+ 7
- 6
Makefile Datei anzeigen

@@ -1,12 +1,13 @@
VERSION = git-20140218
VERSION = git-20140317

PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man

CC = gcc
CFLAGS = -std=c99 -Wall -pedantic -O2 -I$(PREFIX)/include -DHAVE_GIFLIB
LDFLAGS = -L$(PREFIX)/lib
LIBS = -lX11 -lImlib2 -lgif
CC = gcc
CFLAGS = -std=c99 -Wall -pedantic -O2
CPPFLAGS = -I$(PREFIX)/include -D_XOPEN_SOURCE=500 -DHAVE_GIFLIB
LDFLAGS = -L$(PREFIX)/lib
LIBS = -lX11 -lImlib2 -lgif

SRC = commands.c exif.c image.c main.c options.c thumbs.c util.c window.c
OBJ = $(SRC:.c=.o)
@@ -16,7 +17,7 @@ all: sxiv
$(OBJ): Makefile config.h

.c.o:
$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -c -o $@ $<
$(CC) $(CFLAGS) $(CPPFLAGS) -DVERSION=\"$(VERSION)\" -c -o $@ $<

config.h:
cp config.def.h $@


+ 15
- 3
main.c Datei anzeigen

@@ -127,16 +127,28 @@ void check_add_file(char *filename)
filecnt *= 2;
files = (fileinfo_t*) s_realloc(files, filecnt * sizeof(fileinfo_t));
}

#if defined _BSD_SOURCE || defined _XOPEN_SOURCE && \
((_XOPEN_SOURCE - 0) >= 500 || defined _XOPEN_SOURCE_EXTENDED)

if ((files[fileidx].path = realpath(filename, NULL)) == NULL) {
warn("could not get real path of file: %s\n", filename);
return;
}
#else
if (*filename != '/') {
files[fileidx].path = absolute_path(filename);
if (files[fileidx].path == NULL) {
if ((files[fileidx].path = absolute_path(filename)) == NULL) {
warn("could not get absolute path of file: %s\n", filename);
return;
}
} else {
files[fileidx].path = NULL;
}
#endif

files[fileidx].loaded = false;
files[fileidx].name = s_strdup(filename);
if (*filename == '/')
if (files[fileidx].path == NULL)
files[fileidx].path = files[fileidx].name;
if ((bn = strrchr(files[fileidx].name , '/')) != NULL && bn[1] != '\0')
files[fileidx].base = ++bn;


Laden…
Abbrechen
Speichern