aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorEli Zaretskii2000-05-02 11:01:29 +0000
committerEli Zaretskii2000-05-02 11:01:29 +0000
commitfd72561d60188ab9d889064d753975f34caf6b2e (patch)
tree9ce1f4cb105ac5e2b5ebee76045efb518e48fdcc /lib-src
parent820ad5e7e34dc1eaa9b84cbaa46c8db03b581c98 (diff)
downloademacs-fd72561d60188ab9d889064d753975f34caf6b2e.tar.gz
emacs-fd72561d60188ab9d889064d753975f34caf6b2e.zip
(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.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/ebrowse.c21
1 files changed, 15 insertions, 6 deletions
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 @@
57 57
58/* The character used as a separator in path lists (like $PATH). */ 58/* The character used as a separator in path lists (like $PATH). */
59 59
60#if defined(__MSDOS__) || defined(WINDOWSNT)
61#define PATH_LIST_SEPARATOR ';'
62#define FILENAME_EQ(X,Y) (strcasecmp(X,Y) == 0)
63#else
60#define PATH_LIST_SEPARATOR ':' 64#define PATH_LIST_SEPARATOR ':'
65#define FILENAME_EQ(X,Y) (streq(X,Y))
66#endif
61 67
62/* The default output file name. */ 68/* The default output file name. */
63 69
@@ -749,7 +755,7 @@ add_member_decl (cls, name, regexp, pos, hash, var, sc, vis, flags)
749 m = add_member (cls, name, var, sc, hash); 755 m = add_member (cls, name, var, sc, hash);
750 756
751 /* Have we seen a new filename? If so record that. */ 757 /* Have we seen a new filename? If so record that. */
752 if (!cls->filename || !streq (cls->filename, filename)) 758 if (!cls->filename || !FILENAME_EQ (cls->filename, filename))
753 m->filename = filename; 759 m->filename = filename;
754 760
755 m->regexp = regexp; 761 m->regexp = regexp;
@@ -820,7 +826,7 @@ add_member_defn (cls, name, regexp, pos, hash, var, sc, flags)
820 if (!cls->sfilename) 826 if (!cls->sfilename)
821 cls->sfilename = filename; 827 cls->sfilename = filename;
822 828
823 if (!streq (cls->sfilename, filename)) 829 if (!FILENAME_EQ (cls->sfilename, filename))
824 m->def_filename = filename; 830 m->def_filename = filename;
825 831
826 m->def_regexp = regexp; 832 m->def_regexp = regexp;
@@ -919,7 +925,7 @@ add_global_decl (name, regexp, pos, hash, var, sc, flags)
919 if (!found) 925 if (!found)
920 { 926 {
921 if (!global_symbols->filename 927 if (!global_symbols->filename
922 || !streq (global_symbols->filename, filename)) 928 || !FILENAME_EQ (global_symbols->filename, filename))
923 m->filename = filename; 929 m->filename = filename;
924 930
925 m->regexp = regexp; 931 m->regexp = regexp;
@@ -3376,12 +3382,13 @@ open_file (file)
3376 static char *buffer; 3382 static char *buffer;
3377 static int buffer_size; 3383 static int buffer_size;
3378 struct search_path *path; 3384 struct search_path *path;
3385 int flen = strlen (file) + 1; /* +1 for the slash */
3379 3386
3380 filename = xstrdup (file); 3387 filename = xstrdup (file);
3381 3388
3382 for (path = search_path; path && fp == NULL; path = path->next) 3389 for (path = search_path; path && fp == NULL; path = path->next)
3383 { 3390 {
3384 int len = strlen (path->path); 3391 int len = strlen (path->path) + flen;
3385 3392
3386 if (len + 1 >= buffer_size) 3393 if (len + 1 >= buffer_size)
3387 { 3394 {
@@ -3485,10 +3492,12 @@ process_file (file)
3485 } 3492 }
3486 3493
3487 nbytes = fread (inbuffer + nread, 1, READ_CHUNK_SIZE, fp); 3494 nbytes = fread (inbuffer + nread, 1, READ_CHUNK_SIZE, fp);
3488 nread += nbytes; 3495 if (nbytes <= 0)
3489 if (nbytes < READ_CHUNK_SIZE)
3490 break; 3496 break;
3497 nread += nbytes;
3491 } 3498 }
3499 if (nread < 0)
3500 nread = 0;
3492 inbuffer[nread] = '\0'; 3501 inbuffer[nread] = '\0';
3493 3502
3494 /* Reinitialize scanner and parser for the new input file. */ 3503 /* Reinitialize scanner and parser for the new input file. */