1 /*
2     Numdiff - compare putatively similar files,
3     ignoring small numeric differences
4     Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017  Ivano Primi  <ivprimi@libero.it>
5 
6     This program is free software: you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation, either version 3 of the License, or
9     (at your option) any later version.
10 
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef _NUMDIFF_H_
21 #define _NUMDIFF_H_
22 
23 #include "system.h"
24 #include "bitvector.h"
25 
26 #if defined(HAVE_LIBGMP) && !defined(DISABLE_GMP)
27 #define USE_GMP 1
28 #endif /* defined(HAVE_LIBGMP) && !defined(DISABLE_GMP) */
29 
30 /* The type of a hash value.  */
31 typedef size_t hash_value;
32 verify (hash_value_is_unsigned, ! TYPE_SIGNED (hash_value));
33 
34 /* Rotate an unsigned value to the left.  */
35 #define ROL(v, n) ((v) << (n) | (v) >> (sizeof (v) * CHAR_BIT - (n)))
36 
37 /* Given a hash value and a new character, return a new hash value.  */
38 #ifdef _DEBUG_HASHING_
39 #define HASH(h, c) (putc((c), stderr), (c) + ROL (h, 7))
40 #else
41 #define HASH(h, c) ((c) + ROL (h, 7))
42 #endif
43 
44 /* Error codes */
45 #define OK             0
46 #define LINE_INTERR    1
47 #define EOF_REACHED    2
48 #define READING_ERROR  3
49 #define OUT_OF_MEMORY  4
50 /* *** */
51 #define OPEN_FAILED    5
52 #define WRONG_USAGE    6
53 #define FILE_IS_BINARY 7
54 
55 /*
56   Begin section -- Math types
57 */
58 
59 #include"number.h"
60 
61 #ifdef USE_GMP
62 
63 #include<gmp.h>
64 
65 typedef mpf_t Real;
66 typedef struct {
67   mpf_t re, im;
68 } Complex;
69 
70 #else /* not USE_GMP */
71 
72 typedef bc_num Real;
73 typedef struct {
74   bc_num re, im;
75 } Complex;
76 
77 #endif /* USE_GMP */
78 
79 /*
80   End section -- Math types
81 */
82 
83 #define THRLIST_OK              0
84 #define THRLIST_INVALID_FORMAT -1
85 #define THRLIST_INVALID_RANGES -2
86 
87 /*
88   A structure of type 'thrlist_node' is used
89   to construct lists of threshold values.
90 */
91 
92 struct __thrlist_node {
93   Real threshold;               /* the threshold value */
94 
95   /* BEG1-END1 and BEG2-END2 are the ranges of fields    */
96   /* to which the specified THRESHOLD value applies.     */
97   /* The two ranges must have the same length, but refer */
98   /* to different files.                                 */
99 
100   unsigned long beg1, end1;
101   unsigned long beg2, end2;
102 
103   /* DOUBLE_RANGE_SPEC is a boolean value, which is 1 if */
104   /* BEG1-END1 and BEG2-END2  have been both explicitely */
105   /* set via the command line through a specification of */
106   /* the form:                                           */
107   /*                 BEG1-END1:BEG2-END2                 */
108   /* and otherwise is equal to 0.                        */
109 
110   int double_range_spec;
111 
112   /* pointer to the next node in the list */
113   struct __thrlist_node *next;
114 };
115 
116 typedef struct __thrlist_node thrlist_node;
117 
118 /* A pointer to a list of threshold values */
119 typedef thrlist_node *thrlist;
120 
121 struct numfmt {
122   char *currency;    /* currency            */
123   char dp;           /* decimal point       */
124   char thsep;        /* thousands separator */
125   unsigned grouping; /* Number of digits in each group */
126   char pos_sign;     /* positive sign */
127   char neg_sign;     /* negative sign */
128   char ech;          /* prefix for decimal exponent  */
129   char iu;           /* symbol of the imaginary unit */
130 };
131 /* A structure of this type is used to store  */
132 /* information about the legal format for the */
133 /* numbers in input.                          */
134 
135 /*
136   This is the number of the fields in the 'numftm' structure
137   having "char" type. None of them can be a digit and
138   they must have all different values
139   (see the code of the function valid_numfmt() in the file options.c).
140 */
141 #define NUMFMT_CHARS 6
142 
143 typedef struct {
144   unsigned char* ptr;
145   size_t len, size;
146 } flg_array; /* A structure of this type is used to store the information
147 		retrieved from the execution of a diff command */
148 
149 typedef struct {
150   unsigned long lineno1;
151   unsigned long lineno2;
152   unsigned long fieldno1;
153   unsigned long fieldno2;
154 } difference_location; /* A structure of this type is used
155   to store the "location" of a difference between the compared files:
156   (LINENO1,FIELDNO1) and (LINENO2, FIELDNO2) are the positions
157   of the fields which differ */
158 
159 typedef struct {
160   /* Mask of the options */
161   bitvector optmask;
162 
163   /* Output mode. This field can take any of the values */
164   /* OUTMODE_* (see below)                              */
165   int output_mode;
166 
167   /* This is a mask of bits specifying the fields of the first file
168      which must be ignored. */
169   unsigned char ghostmask1[FIELDMASK_SIZE];
170 
171   /* This is a mask of bits specifying the fields of the second file
172      which must be ignored. */
173   unsigned char ghostmask2[FIELDMASK_SIZE];
174 
175   /* This is a mask of bits specifying the fields in the
176      first file for which partial blurring must be enabled during
177      the filtering procedure. */
178   unsigned char pblurmask1[FIELDMASK_SIZE];
179 
180   /* This is a mask of bits specifying the fields in the
181      second file for which partial blurring must be enabled during
182      the filtering procedure. */
183   unsigned char pblurmask2[FIELDMASK_SIZE];
184 
185   /* This is a mask of bits specifying the fields in the
186      first file for which total blurring must be enabled during
187      the filtering procedure. */
188   unsigned char tblurmask1[FIELDMASK_SIZE];
189 
190   /* This is a mask of bits specifying the fields in the
191      second file for which total blurring must be enabled during
192      the filtering procedure. */
193   unsigned char tblurmask2[FIELDMASK_SIZE];
194 
195   /* This parameter specifies how the relative errors */
196   /* have to be computed. It may have one of the      */
197   /* following values:                                */
198   /* CLASSIC_FORMULA            0  (the default one)  */
199   /* WR_TO_FIRST_FILE           1                     */
200   /* WR_TO_SECOND_FILE          2                     */
201   int relerr_formula;
202 
203   /* Tolerance thresholds for absolute and relative errors */
204   thrlist maxabserr, maxrelerr;
205 
206   /* Flag > 0 --> If a numeric field in the first file is greater than the  */
207   /*              corresponding numeric field in the second file, then the  */
208   /*              related difference is ignored, i.e. it is never output    */
209   /* Flag < 0 --> If a numeric field in the first file is less than the     */
210   /*              corresponding numeric field in the second file, then the  */
211   /*              related difference is ignored, i.e. it is never output    */
212   /* Flag = 0 --> Standard behavior: the difference between 2 corresponding */
213   /*              numeric fields (one in the first file, the other one in   */
214   /*              the second file) is always considered and it is output    */
215   /*              whenever its absolute value is greater than the given     */
216   /*              tolerance thresholds for the absolute and relative errors.*/
217   signed char flag;
218 
219   /* Internal scale (number of digits of accuracy) */
220   int iscale;
221 
222   /* Files to be compared */
223   const char *file1, *file2;
224 
225   /* Internal fields separators (IFS) for file1 and file2 */
226   char **ifs1, **ifs2;
227 
228   /* Numeric conventions for file1 (.nf1) and file2 (.nf2) */
229   struct numfmt nf1, nf2;
230 
231 } argslist ; /* A structure of this type is used to store the options */
232 /* set by the user                                                    */
233 
234 typedef struct {
235   /* These variables are used to print statistics */
236   Real Labserr,  Crelerr,  Lrelerr,  Cabserr;
237   Real N1abserr, N1disperr, N2abserr, N2disperr;
238 
239   difference_location Labserr_location, Rabserr_location;
240 
241   int Nentries, Ndisperr;
242 } statlist;
243 
244 enum {
245   _H_MASK=0,  /* -h option, used to recall help */
246   _A_MASK=1,  /* -a option, used to set tolerance for abs. error  */
247   _R_MASK=2,  /* -r option, used to set tolerance for rel. error  */
248   _2_MASK=3,  /* -2 option, used to enable the "strict" control */
249   _S_MASK=4,  /* -s option, used to explicitly set IFS  */
250   _B_MASK=5,  /* -b option, used to enable the "brief" mode */
251   _F_MASK=6,  /* -f option, used to enable the "filter-only" mode */
252   _Q_MASK=7,  /* -q option, used to enable "quiet" mode */
253   _X_MASK=8,  /* -# option, used to set the precision   */
254   _D_MASK=9,  /* -d option, used to set the decimal point */
255   _T_MASK=10, /* -t option, used to set the thousands separator */
256   _G_MASK=11, /* -g option, used to set the group length */
257   _P_MASK=12, /* -p option, used to set the character 'positive sign' */
258   _N_MASK=13, /* -n option, used to set the character 'negative sign' */
259   _E_MASK=14, /* -e option, used to set prefix for decimal exponent */
260   _I_MASK=15, /* -i option, used to set the symbol of the imaginary unit */
261   _L_MASK=16, /* -l option, to redirect the standard error on a file */
262   _O_MASK=17, /* -o option, to redirect the standard output on a file */
263   _Z_MASK=18, /* -z option, to activate the filter (normal mode) */
264   _SZ_MASK=19,/* -Z option, to activate the filter (alternative mode) */
265   _SX_MASK=20,/* -X option, used to select which fields in the
266 		 lines of the files must be ignored */
267   _SP_MASK=21,/* -P option, used to ignore negative errors */
268   _SN_MASK=22,/* -N option, used to ignore positive errors */
269   _SU_MASK=23,/* -U option, used to enable the "dummy" mode */
270   _SE_MASK=24,/* -E option, used to enable the "essential" mode */
271   _SV_MASK=25,/* -V option, used to enable the "verbose" mode */
272   _SO_MASK=26,/* -O option, used to enable the "overview" mode */
273   _SS_MASK=27,/* -S option, used to print statistics */
274   _SI_MASK=28,/* -I option, used to ignore case while comparing
275 		 non numerical field */
276   _SH_MASK=29,/* -H option, by filtering assume large files and
277 		 many scattered small changes */
278   _M_MASK=30, /* -m option, by filtering try hard to find a smaller
279 		 set of changes */
280   _ST_MASK=31,/* -T option, to expand tabs in spaces */
281   _SB_MASK=32,/* -B option, to treat both files as binary files */
282   _SD_MASK=33,/* -D option, used to set the field delimiters */
283   _SF_MASK=34,/* -F option, used to set the formula for computing
284 		 the relative errors */
285   _C_MASK=35, /* -c option, used to set the currency name(symbol) */
286   _RAW_MASK=36, /* --raw option, to print the differences in raw format */
287   _V_MASK=37, /* -v option, used to show version number,
288 		 Copyright and No-Warrany */
289   MAX_NUMDIFF_OPTIONS = 100
290 };
291 
292 /* Output modes: verbose, normal, brief, and quiet.     */
293 /* Do not change the relative order of the values of    */
294 /* these macros, the code in cmp_lines()  (see file     */
295 /* cmpfns.c) relies on the fact that:                   */
296 /* OUTMODE_VERBOSE > OUTMODE_NORMAL > OUTMODE_COINCISE  */
297 /* > OUTMODE_BRIEF > OUTMODE_QUIET  > OUTMODE_OVERVIEW, */
298 /* and OUTMODE_OVERVIEW > OUTMODE_RAW.                  */
299 
300 enum {
301   OUTMODE_VERBOSE=    4,
302   OUTMODE_NORMAL=     3,
303   OUTMODE_COINCISE=   2,
304   OUTMODE_BRIEF=      1,
305   OUTMODE_QUIET=      0,
306   OUTMODE_OVERVIEW=  -1,
307   OUTMODE_RAW=       -2
308 };
309 
310 /* Methods to compute the relative differences */
311 
312 enum {
313   CLASSIC_FORMULA=        0,
314   WR_TO_FIRST_FILE=       1,
315   WR_TO_SECOND_FILE=      2
316 };
317 
318 #ifndef PACKAGE
319 #define PACKAGE "numdiff"
320 #endif
321 
322 #ifndef LOCALEDIR
323 #define LOCALEDIR "/usr/local/share/locale/"
324 #endif
325 
326 /* The character representing the number zero */
327 
328 #define CHAR_ZERO '0'
329 
330 /* The character representing the number one */
331 
332 #define CHAR_ONE '1'
333 
334 /* The character representing the number nine */
335 
336 #define CHAR_NINE '9'
337 
338 /* newline character */
339 
340 #define NEWLINE '\n'
341 
342 /*
343   Predefined values for
344   .nf*.currency (currency name)
345   .nf*.dp       (decimal point)
346   .nf*.thsep    (thousands separator)
347   .nf*.grouping (number of digits in each thousands group)
348   .nf*.pos_sign (positive sign)
349   .nf*.neg_sign (negative sign)
350   .nf*.ech      (prefix for decimal exponent)
351   .nf*.iu       (symbol of the imaginary unit)
352   .iscale      (decimal digits of accuracy)
353 */
354 #define CURRENCY  ""
355 #define DP        '.'
356 #define THSEP     ','
357 #define GROUPING   3
358 #define POS_SIGN  '+'
359 #define NEG_SIGN  '-'
360 #define ECH       'e'
361 #define IU        'i'
362 #define ISCALE    35
363 
364 
365 /*
366   Largest possible value for .iscale
367 */
368 #define MAX_ISCALE  180
369 
370 /*
371   Largest possible exponent accepted by Numdiff
372   when a number is written in scientific notation
373 */
374 #define MAX_EXPN    +1073741824L
375 
376 /*
377   Lowest possible exponent accepted by Numdiff
378   when a number is written in scientific notation
379 */
380 #define MIN_EXPN    -1073741824L
381 
382 /*
383   Macro to move ahead a pointer
384 */
385 #define move_ahead(ptr) ptr++
386 
387 /*
388   Character classification macros.
389   The macro CTYPE_DOMAIN is defined in "system.h".
390 */
391 #define is_digit(c) ((unsigned int) (c) - '0' <= 9 ? 1 : 0)
392 #define is_punct(c) (CTYPE_DOMAIN((unsigned char)(c)) && ispunct((unsigned char)(c)))
393 #define is_print(c) (CTYPE_DOMAIN((unsigned char)(c)) && isgraph((unsigned char)(c)) && ((unsigned int) (c) - '0' > 9))
394 #define is_space(c) (CTYPE_DOMAIN((unsigned char)(c)) && isspace((unsigned char)(c)))
395 
396 /*
397   Mathematical functions
398 */
399 
400 int      cmp (Real p, Real q);
401 int      is0 (Real u);
402 int      smart_cmp (const Complex* pz1, const Complex* pz2, int flag);
403 void     printno (Real u, int m);
404 
405 extern Real Zero, Inf;
406 
407 void     init_mpa(int iscale);
408 
409 void     initR (Real* px);
410 void     initC (Complex* pz);
411 
412 void copyR (Real* dst, Real src);
413 void copyC (Complex* dst, Complex src);
414 
415 #ifdef _MPA_DEBUG
416 void     debug_printno (Real u, int m);
417 #endif /* _MPA_DEBUG */
418 
419 void     str2R (const char *q, char **endptr, int iscale,
420 		const struct numfmt* pnf, Real* pr);
421 void     str2C (const char *q, char **endptr, int iscale,
422 		const struct numfmt* pnf, Complex* pc);
423 
424 void     add (Real s, Real t, Real* q, int iscale);
425 void     square (Real s, Real* q, int iscale);
426 void     divide (Real s, Real t, Real* q, int iscale);
427 void     divide_by_int (Real* q, int d, int iscale);
428 void     square_root (Real* q, int iscale);
429 
430 void     Cabs (Complex z, Real* pm, int iscale);
431 void     Csub (Complex z1, Complex z2, Complex* pw, int iscale);
432 
433 void     delR (Real* px);
434 void     delC (Complex* pz);
435 
436 void     end_mpa(void);
437 
438 /*
439   Functions used to manipulate lists of threshold specifications (see thrlist.c)
440 */
441 
442 thrlist thrlist_new (void);
443 int thrlist_add (thrlist *plist, const char* def);
444 int thrlist_cmp (Real r, thrlist list, unsigned long fieldno1, unsigned long fieldno2);
445 void thrlist_dispose (thrlist *plist);
446 
447 
448 /* Shared definitions coming from GNU DIFF
449 
450    Copyright (C) 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1998, 2001,
451    2002 Free Software Foundation, Inc.
452 
453    This file is part of GNU DIFF.
454 
455    GNU DIFF is free software; you can redistribute it and/or modify
456    it under the terms of the GNU General Public License as published by
457    the Free Software Foundation; either version 2, or (at your option)
458    any later version.
459 
460    GNU DIFF is distributed in the hope that it will be useful,
461    but WITHOUT ANY WARRANTY; without even the implied warranty of
462    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
463    GNU General Public License for more details.
464 
465    You should have received a copy of the GNU General Public License
466    along with this program; see the file COPYING.
467    If not, write to the Free Software Foundation,
468    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
469 
470 #include <stdio.h>
471 
472 #define TAB_WIDTH 8
473 
474 /*
475   Added by Ivano Primi, July 31 2008
476 */
477 #define MIN_ATMOST_NCOLS 16
478 #define DEF_ATMOST_NCOLS 130
479 #define MAX_ATMOST_NCOLS 512
480 
481 /* What kind of changes a hunk contains.  */
482 enum changes
483 {
484   /* No changes: lines common to both files.  */
485   UNCHANGED,
486 
487   /* Deletes only: lines taken from just the first file.  */
488   OLD,
489 
490   /* Inserts only: lines taken from just the second file.  */
491   NEW,
492 
493   /* Both deletes and inserts: a hunk containing both old and new lines.  */
494   CHANGED
495 };
496 
497 /* Variables for command line options */
498 
499 #ifndef GDIFF_OPTIONS
500 # define XTERN extern
501 #else
502 # define XTERN
503 #endif
504 
505 /* The significance of white space during comparisons.  */
506 XTERN enum
507 {
508   /* All white space is significant (the default).  */
509   IGNORE_NO_WHITE_SPACE,
510 
511   /* Ignore changes due to tab expansion.  */
512   IGNORE_TAB_EXPANSION,
513 
514   /* Ignore changes in horizontal white space.  */
515   IGNORE_SPACE_CHANGE,
516 
517   /* Ignore all horizontal white space.  */
518   IGNORE_ALL_SPACE
519 } ignore_white_space;
520 
521 /* Treat both files as binary files (meaningful only under Doz/Windoz) */
522 XTERN bool binary;
523 
524 /* Nonzero means to not show common lines.  */
525 XTERN bool suppress_common_lines;
526 
527 /* Expand tabs in the output so the text lines up properly
528    despite the characters added to the front of each line (-T).  */
529 XTERN bool expand_tabs;
530 
531 /* The half line width and column 2 offset for OUTPUT_SDIFF.  */
532 XTERN unsigned int sdiff_half_width;
533 XTERN unsigned int sdiff_column2_offset;
534 
535 /* Use heuristics for better speed with large files with a small
536    density of changes.  */
537 XTERN bool speed_large_files;
538 
539 /* Name of program the user invoked (for error messages).  */
540 XTERN char *program_name;
541 
542 /* The result of comparison is an "edit script": a chain of `struct change'.
543    Each `struct change' represents one place where some lines are deleted
544    and some are inserted.
545 
546    LINE0 and LINE1 are the first affected lines in the two files (origin 0).
547    DELETED is the number of lines deleted here from file 0.
548    INSERTED is the number of lines inserted here in file 1.
549 
550    If DELETED is 0 then LINE0 is the number of the line before
551    which the insertion was done; vice versa for INSERTED and LINE1.  */
552 
553 struct change
554 {
555   struct change *link;		/* Previous or next edit command  */
556   lin inserted;			/* # lines of file 1 changed here.  */
557   lin deleted;			/* # lines of file 0 changed here.  */
558   lin line0;			/* Line number of 1st deleted line.  */
559   lin line1;			/* Line number of 1st inserted line.  */
560   bool ignore;			/* Flag used in context.c.  */
561 };
562 
563 /* Structures that describe the input files.  */
564 
565 /* Data on one input file being compared.  */
566 
567 struct file_data {
568     int             desc;	/* File descriptor  */
569     char const      *name;	/* File name  */
570     struct stat     stat;	/* File status */
571 
572     /* Buffer in which text of file is read.  */
573     word *buffer;
574 
575     /* Allocated size of buffer, in bytes.  Always a multiple of
576        sizeof *buffer.  */
577     size_t bufsize;
578 
579     /* Number of valid bytes now in the buffer.  */
580     size_t buffered;
581 
582     /* Array of pointers to lines in the file.  */
583     char const **linbuf;
584 
585     /* linbuf_base <= buffered_lines <= valid_lines <= alloc_lines.
586        linebuf[linbuf_base ... buffered_lines - 1] are possibly differing.
587        linebuf[linbuf_base ... valid_lines - 1] contain valid data.
588        linebuf[linbuf_base ... alloc_lines - 1] are allocated.  */
589     lin linbuf_base, buffered_lines, valid_lines, alloc_lines;
590 
591     /* Pointer to end of prefix of this file to ignore when hashing.  */
592     char const *prefix_end;
593 
594     /* Count of lines in the prefix.
595        There are this many lines in the file before linbuf[0].  */
596     lin prefix_lines;
597 
598     /* Pointer to start of suffix of this file to ignore when hashing.  */
599     char const *suffix_begin;
600 
601     /* Vector, indexed by line number, containing an equivalence code for
602        each line.  It is this vector that is actually compared with that
603        of another file to generate differences.  */
604     lin *equivs;
605 
606     /* Vector, like the previous one except that
607        the elements for discarded lines have been squeezed out.  */
608     lin *undiscarded;
609 
610     /* Vector mapping virtual line numbers (not counting discarded lines)
611        to real ones (counting those lines).  Both are origin-0.  */
612     lin *realindexes;
613 
614     /* Total number of nondiscarded lines.  */
615     lin nondiscarded_lines;
616 
617     /* Vector, indexed by real origin-0 line number,
618        containing TRUE for a line that is an insertion or a deletion.
619        The results of comparison are stored here.  */
620     bool *changed;
621 
622     /* 1 if file ends in a line with no final newline.  */
623     bool missing_newline;
624 
625     /* 1 if at end of file.  */
626     bool eof;
627 
628     /* 1 more than the maximum equivalence value used for this or its
629        sibling file.  */
630     lin equiv_max;
631 };
632 
633 /* The file buffer, considered as an array of bytes rather than
634    as an array of words.  */
635 #define FILE_BUFFER(f) ((char *) (f)->buffer)
636 
637 /* Describe the two files currently being compared.  */
638 
639 XTERN struct file_data files[2];
640 
641 /* Stdio stream to output diffs to.  */
642 
643 #define outfile stdout
644 
645 /* Declare various functions.  */
646 
647 /* analyze.c */
648 int diff_2_files (struct file_data[], const argslist*);
649 
650 /* inout.c */
651 bool read_files (struct file_data[], const argslist*);
652 
653 /* numutil.c */
654 char* acxnum (const char *str, const struct numfmt* pnf);
655 int compare_numeric_strings (const char *str1, const struct numfmt* pnf1,
656 			     const char *str2, const struct numfmt* pnf2);
657 char* hcxnum (const char *str, const struct numfmt* pnf, hash_value *ph);
658 #ifdef USE_GMP
659 int mpf_a2num (Real* pr, const char *q, char** endptr, const struct numfmt* pnf);
660 #endif /* USE_GMP */
661 
662 /* side.c */
663 void print_sdiff_script (struct change *);
664 void print_1overview_line (const char *left, int are_different, const char *right);
665 
666 /* util.c */
667 bool lines_differ (char const *, char const *, int, int, const argslist*);
668 void *zalloc (size_t);
669 
670 #define stralloc(length) zalloc ((length)+1)
671 
672 enum changes analyze_hunk (struct change *, lin *, lin *, lin *, lin *);
673 #ifdef _DEBUG_SCRIPT_
674 void debug_script (struct change *);
675 #endif
676 void perror_with_name (char const *);
677 void pfatal_with_name (char const *) __attribute__((noreturn));
678 void print_script (struct change *, void (*) (struct change *));
679 
680 /* flags.c */
681 /* This functions were added by Ivano Primi, 14-02-08 */
682 
683 int init_flags (void);
684 int print_flags (FILE* fp);
685 flg_array copy_of_intflagtab (void);
686 void erase_flags (void);
687 void notedown_sdiff_script (struct change *script);
688 
689 /* End Section "Shared definitions coming from GNU DIFF" */
690 
691 #endif /* _NUMDIFF_H_ */
692