From: Eli Zaretskii Date: Tue, 2 May 2000 11:01:29 +0000 (+0000) Subject: (PATH_LIST_SEPARATOR) [__MSDOS__ || WINDOWSNT]: Define X-Git-Tag: emacs-pretest-21.0.90~4084 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fd72561d60188ab9d889064d753975f34caf6b2e;p=emacs.git (PATH_LIST_SEPARATOR) [__MSDOS__ || WINDOWSNT]: Define to semi-colon. (FILENAME_EQ): New macro, for comparing file names. (add_member_decl, add_global_decl, add_member_defn): Use FILENAME_EQ. (process_file): Don't assume that fread always reads as many bytes as it was told to (DOS-style CR-LF text files fail this logic). (open_file): Allocate enough space for path->path plus the file name and the slash. --- diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c index de8f7b9f920..4e344a8bc11 100644 --- a/lib-src/ebrowse.c +++ b/lib-src/ebrowse.c @@ -57,7 +57,13 @@ /* The character used as a separator in path lists (like $PATH). */ +#if defined(__MSDOS__) || defined(WINDOWSNT) +#define PATH_LIST_SEPARATOR ';' +#define FILENAME_EQ(X,Y) (strcasecmp(X,Y) == 0) +#else #define PATH_LIST_SEPARATOR ':' +#define FILENAME_EQ(X,Y) (streq(X,Y)) +#endif /* The default output file name. */ @@ -749,7 +755,7 @@ add_member_decl (cls, name, regexp, pos, hash, var, sc, vis, flags) m = add_member (cls, name, var, sc, hash); /* Have we seen a new filename? If so record that. */ - if (!cls->filename || !streq (cls->filename, filename)) + if (!cls->filename || !FILENAME_EQ (cls->filename, filename)) m->filename = filename; m->regexp = regexp; @@ -820,7 +826,7 @@ add_member_defn (cls, name, regexp, pos, hash, var, sc, flags) if (!cls->sfilename) cls->sfilename = filename; - if (!streq (cls->sfilename, filename)) + if (!FILENAME_EQ (cls->sfilename, filename)) m->def_filename = filename; m->def_regexp = regexp; @@ -919,7 +925,7 @@ add_global_decl (name, regexp, pos, hash, var, sc, flags) if (!found) { if (!global_symbols->filename - || !streq (global_symbols->filename, filename)) + || !FILENAME_EQ (global_symbols->filename, filename)) m->filename = filename; m->regexp = regexp; @@ -3376,12 +3382,13 @@ open_file (file) static char *buffer; static int buffer_size; struct search_path *path; + int flen = strlen (file) + 1; /* +1 for the slash */ filename = xstrdup (file); for (path = search_path; path && fp == NULL; path = path->next) { - int len = strlen (path->path); + int len = strlen (path->path) + flen; if (len + 1 >= buffer_size) { @@ -3485,10 +3492,12 @@ process_file (file) } nbytes = fread (inbuffer + nread, 1, READ_CHUNK_SIZE, fp); - nread += nbytes; - if (nbytes < READ_CHUNK_SIZE) + if (nbytes <= 0) break; + nread += nbytes; } + if (nread < 0) + nread = 0; inbuffer[nread] = '\0'; /* Reinitialize scanner and parser for the new input file. */