diff -uNr a/vtools/Makefile b/vtools/Makefile --- a/vtools/Makefile ae3d7fe005038f18760ef9c78e0aa83bead91fe39020238ff712e46cd52682d0da8ddf2067cdc77247c1466564caf7089b5670cb7ea684b0076f7aa125945351 +++ b/vtools/Makefile 30959920906cdf36872b949334b762f96f0349ece83b040d67c1d551e4deb436aec54afe6767b1ef1e721d99550c72e3d2a5cc83537dc622d50ca93d9261e19d @@ -30,7 +30,7 @@ OBJECTS=$(SRCS:.c=.o) vdiff: $(SOURCES) $(HEADERS) - $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -std=c99 -Ilib/ -Isrc/ -o $@ $(SOURCES) + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -std=c99 -pedantic -Ilib/ -Isrc/ -o $@ $(SOURCES) clean: @rm -f vdiff diff -uNr a/vtools/lib/xalloc.h b/vtools/lib/xalloc.h --- a/vtools/lib/xalloc.h 2146359188e16e7186846ae0b1026dc41bb7ec2c58fce67d3f02f99bdb851f9325483084b55ffd5bcb4b0d36c08799bf3198baaedf7595b6e0ee85a042806446 +++ b/vtools/lib/xalloc.h bb116548d11fb1b72bd214fdcbc29bdc260a10783555acb33972f9fea19332da586048e72aed60cf809dab53dacb8d037e12a9de28709e8f1c67aca1e9b9e3de @@ -10,7 +10,7 @@ gnulib's xalloc-die module. This is the function to call when one wants the program to die because of a memory allocation failure. */ -extern _Noreturn void xalloc_die(void); +extern void xalloc_die(void) __attribute__((noreturn)); void *xmalloc(size_t s); void *xzalloc(size_t s); diff -uNr a/vtools/manifest b/vtools/manifest --- a/vtools/manifest aab77ccf9c4fa86348f84d661509cf482f958d1a1ed4a55f608683510a8c5ab3e3a12e6c9fa61b6ddf31a493d5be586ef7362d00e1d91542a130b27ec0dc5ad3 +++ b/vtools/manifest 29ca97ffc8fcd1d9a08809f46d6dfbc58da2e139d63001e84b53fe027c7cda61d3170320d097d092b5c0e4e2886a984f17fe94e9988f26c4bcde526be3fe5efc @@ -1 +1,2 @@ 510300 phf vtools_genesis Initial release of vtools. Genesis contains stripped down version of diffutils 3.6, with most of functionality not relevant to vpatch removed. +511300 phf vdiff_fixes_newline_gcc Fixes for C99 compatability, support for "No newline at end of file" directive. diff -uNr a/vtools/src/analyze.c b/vtools/src/analyze.c --- a/vtools/src/analyze.c 7c13ede685f2c92f24a015e44b9609494e4d5da9bc6a192b62a9cab92f36c2543f5092fdadd7436feac45ca0ab54d19ea0692848c5c94f9819b885beec08e179 +++ b/vtools/src/analyze.c 0626cff1e1871b60ebe1843368954151aa16905f5a26a3bc9a0e9df97eab432042377a5e85928ae3144f88800c8691fa7d6aa362529fa37ea789252c540fd520 @@ -579,14 +579,6 @@ p = e->link; free(e); } - - for (f = 0; f < 2; ++f) - if (cmp->file[f].missing_newline) { - error(0, 0, "%s: %s\n", - file_label[f] ? file_label[f] : cmp->file[f].name, - "No newline at end of file"); - changes = 2; - } } if (cmp->file[0].buffer != cmp->file[1].buffer) diff -uNr a/vtools/src/io.c b/vtools/src/io.c --- a/vtools/src/io.c 9ab0950eff37136222dc461537f8448ebc36dff595e77af294e48f9142657ed6da78d72c232ecc890e28ba75a2160d7ab3a09e1a7aa61c50ac95c7a747ef2b7a +++ b/vtools/src/io.c 7106411c84c6bc2d4ea1027d66b6b1a6278106c5fc2d9c4f990d8d4d762eddeda8eac3441bf3b40129167750b56d210228c2a0e437a707e89fe32de1a4237e99 @@ -196,6 +196,15 @@ bucket = &buckets[h % nbuckets]; length = p - ip - 1; + if (p == bufend + && current->missing_newline) { + /* The last line is incomplete. If the line cannot + compare equal to any complete line, put it into + buckets[-1] so that it can compare equal only to the + other file's incomplete line (if one exists). */ + bucket = &buckets[-1]; + } + for (i = *bucket;; i = eqs[i].next) if (!i) { /* Create a new equivalence class in this bucket. */ @@ -271,9 +280,9 @@ linbuf[line] = p; if (p == bufend) { - /* If the last line is incomplete and we do not silently - complete lines, don't count its appended newline. */ - if (current->missing_newline && false) /* our output style not robust */ + /* If the last line is incomplete, don't count its + appended newline. */ + if (current->missing_newline) linbuf[line]--; break; } @@ -395,10 +404,9 @@ /* Don't mistakenly count missing newline as part of prefix. */ - if (false - && ((buffer0 + n0 - filevec[0].missing_newline < p0) - != - (buffer1 + n1 - filevec[1].missing_newline < p1))) + if ((buffer0 + n0 - filevec[0].missing_newline < p0) + != + (buffer1 + n1 - filevec[1].missing_newline < p1)) p0--, p1--; }