Diffs from 3.13. Various minor fixes/improvements. Win32 binaries have this patch applied. -uwe Index: externs.h =================================================================== RCS file: /home/uwe/repository/lout/externs.h,v retrieving revision 1.1.1.1 retrieving revision 1.3 diff -u -r1.1.1.1 -r1.3 --- externs.h 1999/02/14 15:52:50 1.1.1.1 +++ externs.h 1999/02/14 15:59:15 1.3 @@ -2584,12 +2584,11 @@ /***** z39.c String Handler **************************************/ #define AsciiToFull(x) ( (FULL_CHAR *) (x) ) -#if COLLATE #define StringEqual(a, b) (strcoll((char *)(a), (char *)(b))==0) +#if !COLLATE #define StringLessEqual(a, b) (strcoll((char*)(a),(char*)(b))<=0) #else -#define StringEqual(a, b) (strcmp((char *)(a), (char *)(b))==0) -#define StringLessEqual(a, b) (strcmp((char*)(a),(char*)(b))<=0) +extern BOOLEAN StringLessEqual(FULL_CHAR *a, FULL_CHAR *b); #endif #define StringCat(a, b) strcat((char *)(a),(char *)(b)) #define StringCopy(a, b) strcpy((char *)(a),(char *)(b)) @@ -2836,6 +2835,7 @@ #define debugcond3(cat, urg, cond, str, p1, p2, p3) #define debugcond4(cat, urg, cond, str, p1, p2, p3, p4) #define debugcond5(cat, urg, cond, str, p1, p2, p3, p4, p5) +#define debugcond6(cat, urg, cond, str, p1, p2, p3, p4, p5, p6) #define ifdebugcond(cat, urg, cond, x) #define debug_init(str) Error(1, 4, "%s - debug flags not implemented", \ FATAL, no_fpos, str) Index: makefile =================================================================== RCS file: /home/uwe/repository/lout/makefile,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- makefile 1999/02/14 15:52:53 1.1.1.1 +++ makefile 1999/02/14 16:19:33 1.2 @@ -222,13 +222,13 @@ # # # (18) If the usual size of a piece of paper at your site is not A4, you # # might like to now change the default value of the @PageType option # -# on line 1607 of file $(LIBDIR)/include/dlf. You can find the list of # -# known page types in the User's Guide, and also at line 2707 in file # -# $(LIBDIR)/include/dlf. # +# on line 57 of file $(LIBDIR)/include/dsf. You can find the list of # +# known page types in the User's Guide, and also at line 585 in file # +# $(LIBDIR)/include/dsf. # # # # (19) If the usual language at your site is not English, you might like to # # now change the default value of the @InitialLanguage option on line # -# 1589 of file $(LIBDIR)/include/dlf. This will mean that by default # +# 255 of file $(LIBDIR)/include/bsf. This will mean that by default # # the date and words like Chapter and July will appear in a different # # language, and hyphenation will be carried out according to patterns # # designed for that language. You can find the list of known languages # Index: z01.c =================================================================== RCS file: /home/uwe/repository/lout/z01.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- z01.c 1999/02/14 15:52:50 1.1.1.1 +++ z01.c 1999/02/26 12:30:27 1.2 @@ -30,6 +30,16 @@ /*****************************************************************************/ #include "externs.h" +/* On DOS/Win32 we need to set binary mode on stdout */ +#if OS_DOS +#include +#include +#ifdef __DJGPP__ +#define _setmode(fd, mode) setmode((fd), (mode)) +#define _fileno(stream) fileno((stream)) +#endif +#endif + /*****************************************************************************/ /* */ @@ -619,8 +629,9 @@ #if OS_DOS /* For DOS/Win32 we need to set binary mode on stdout to prevent PDF compressed streams and xrefs from being corrupted - Uwe 12/98 */ - if (_setmode(_fileno(stdout), _O_BINARY) == -1) - Error(1,27, "cannot set binary mode on stdout", FATAL, no_fpos); + if (BackEnd != PLAINTEXT) + if (_setmode(_fileno(stdout), _O_BINARY) == -1) + Error(1,27, "cannot set binary mode on stdout", FATAL, no_fpos); #endif out_fp = stdout; } Index: z24.c =================================================================== RCS file: /home/uwe/repository/lout/z24.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- z24.c 1999/02/14 15:52:53 1.1.1.1 +++ z24.c 1999/02/24 20:34:49 1.2 @@ -811,7 +811,8 @@ /* acc = MapTable[m]->map[MAP_ACCENT]; */ for( p++; *p; p++ ) { - KernLength(word_font(x), unacc, *(p-1), *p, ksize); + KernLength(font_num(finfo[word_font(x)].original_font), + unacc, *(p-1), *p, ksize); if ( ksize != 0 ) { PDFText_Kern(out_fp, ksize); Index: z39.c =================================================================== RCS file: /home/uwe/repository/lout/z39.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- z39.c 1999/02/14 15:52:53 1.1.1.1 +++ z39.c 1999/02/14 15:59:49 1.2 @@ -54,6 +54,18 @@ /*****************************************************************************/ +#if COLLATE /* otherwise defined as a macro in externs.h */ +/* NB: must match compare() in z45.c */ +BOOLEAN StringLessEqual(FULL_CHAR *a, FULL_CHAR *b) +{ + int coll = strcoll ((char *)a, (char *)b); + if (coll == 0) /* then disambiguate with strcmp */ + coll = strcmp ((char *)a, (char *)b); + return coll <= 0; +} +#endif /* COLLATE */ + + /*@::StringBeginsWith(), StringContains(), StringInt(), StringFiveInt()@******/ /* */ /* BOOLEAN StringBeginsWith(str, pattern) */ Index: z45.c =================================================================== RCS file: /home/uwe/repository/lout/z45.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- z45.c 1999/02/14 15:52:53 1.1.1.1 +++ z45.c 1999/02/14 16:12:50 1.2 @@ -120,8 +120,10 @@ { char *text; /* Text of the line. */ int length; /* Length not including final newline. */ - char *keybeg; /* Start of first key. */ - char *keylim; /* Limit of first key. */ +#if COLLATE + char *xfrm; /* == strxfrm(text) */ + int xfrmlen; /* Length not including final zero byte */ +#endif }; /* Arrays of lines. */ @@ -343,6 +345,14 @@ lines->lines[lines->used].text = beg; lines->lines[lines->used].length = ptr - beg; +#if COLLATE + { + int xfrmlen = strxfrm ((char *) 0, beg, 0); + lines->lines[lines->used].xfrmlen = xfrmlen; + lines->lines[lines->used].xfrm = (char *) xmalloc (xfrmlen + 1); + strxfrm (lines->lines[lines->used].xfrm, beg, xfrmlen); + } +#endif /* COLLATE */ ++lines->used; beg = ptr + 1; @@ -351,51 +361,67 @@ buf->left = lim - beg; } +/* Auxiliary function to compare strings A and B that have lengths + ALEN and BLEN, respectively. */ +static int +compare_ascii (a, alen, b, blen) + register char *a, *b; + register int alen, blen; +{ + int diff, mini; + + mini = find_min(alen, blen); + if (mini == 0) + diff = alen - blen; + else + { + diff = *a - *b; + if (diff == 0) + { + diff = memcmp (a, b, mini); + if (diff == 0) + diff = alen - blen; + } + } + return diff; +} + + /* Compare two lines A and B, returning negative, zero, or positive - depending on whether A compares less than, equal to, or greater than B. */ + depending on whether A compares less than, equal to, or greater than B. + NB: must match StringLessEqual */ #if COLLATE + static int compare (a, b) register struct line *a, *b; { int tmpa, tmpb, mini; - tmpa = a->length, tmpb = b->length; - mini = find_min(tmpa, tmpb); - if (mini == 0) - return tmpa - tmpb; - else - return strcoll (a->text, b->text); + tmpa = a->length, tmpb = b->length; + mini = find_min(tmpa, tmpb); + if (mini == 0) + return tmpa - tmpb; + else + { /* NB: see StringLessEqual in z39.c */ + int coll = compare_ascii (a->xfrm, a->xfrmlen, b->xfrm, b->xfrmlen); + if (coll == 0) /* then disambiguate */ + coll = compare_ascii (a->text, a->length, b->text, b->length); + return coll; + } } -#else /* !COLLATE -- good old ASCIIbetical order */ +#else /* !COLLATE */ /* good old ASCIIbetical order */ +/* __inline */ /* ANSI don't have `inline' (C9X will have) */ static int compare (a, b) - register struct line *a, *b; + struct line *a, *b; { - int diff, tmpa, tmpb, mini; - - tmpa = a->length, tmpb = b->length; - mini = find_min(tmpa, tmpb); - if (mini == 0) - diff = tmpa - tmpb; - else - { - char *ap = a->text, *bp = b->text; - - diff = *ap - *bp; - if (diff == 0) - { - diff = memcmp (ap, bp, mini); - if (diff == 0) - diff = tmpa - tmpb; - } - } - - return diff; + return compare_ascii (a->text, a->length, b->text, b->length); } + #endif /* !COLLATE */ /* Sort the array LINES with NLINES members, using TEMP for temporary space. */ @@ -439,10 +465,9 @@ for (lo = lines, nlo = nlines - nhi, t = temp; nlo; --nlo) *lo++ = *t++; } - -/* Sort NFILES FILES onto OFP. */ -void SortFile(char *infile, char *outfile) /* name changed from sort_one by JK */ +/* name changed from sort_one by JK */ +void SortFile(char *infile, char *outfile) { struct buffer buf; struct lines lines; @@ -474,6 +499,9 @@ for (i = 0; i < lines.used; ++i) { xfwrite (lines.lines[i].text, 1, lines.lines[i].length, ofp); +#if COLLATE + free (lines.lines[i].xfrm); +#endif putc ('\n', ofp); } } Index: z48.c =================================================================== RCS file: /home/uwe/repository/lout/z48.c,v retrieving revision 1.1.1.1 retrieving revision 1.5 diff -u -r1.1.1.1 -r1.5 --- z48.c 1999/02/14 15:52:53 1.1.1.1 +++ z48.c 1999/02/25 15:50:43 1.5 @@ -40,6 +40,9 @@ #define PI 3.1415926535897931160 +/* lout headers */ +#include "externs.h" + /* ANSI headers */ #include #include @@ -50,9 +53,6 @@ #include "zlib.h" #endif -/* lout headers */ -#include "externs.h" - static void Assert(BOOLEAN condition, FILE_POS *inFilePos) { if (!condition) /* allows me to set a breakpoint here */ @@ -366,8 +366,6 @@ #ifdef USE_MATRICES static t_matrix g_cur_matrix; static t_matrix_entry_ptr g_matrix_stack; -#else -static int g_text_font_size_in_ems; /* for kerning */ #endif /* track these values in case they are ever required */ @@ -1490,7 +1488,6 @@ (int) (g_page_v_scale_factor * in_font_size)); #else sprintf(str, "%s %u Tf\n", entry->m_PDF_font_name, in_font_size); - g_text_font_size_in_ems = /* g_page_v_scale_factor * */ in_font_size; #endif #if 1 @@ -1720,14 +1717,8 @@ /* void PDFText_Kern(FILE* in_fp, int in_kern) */ /* */ /* Apply kerning to a text string. */ -/* */ -/* Note: because Lout defines a separate table of font sizes for each use */ -/* of a different font size in any font family, we get passed the converted */ -/* size in the "in_kern" parameter. This value has rounding errors which */ -/* can (and probably do) result in small errors in the PDF kerning. */ /* */ -/* Ideally, the original kerning value (as in the Adobe font definition */ -/* files) should be used but there is no access to this value. */ +/* Note: in_kern is in 1/1000 of font size */ /* */ /*****************************************************************************/ @@ -1735,7 +1726,7 @@ { t_tempbuf str; - sprintf(str, ")%d(", -in_kern * 1000 / g_text_font_size_in_ems); + sprintf(str, ")%d(", -in_kern); PDFPage_Write(in_fp, str); } @@ -3047,24 +3038,21 @@ g_page_contents_obj_num = 0; /* undefined */ g_page_length_obj_num = 0; /* undefined */ g_page_start_offset = 0; /* undefined */ - g_text_font_size_in_ems = 0; /* undefined */ g_page_h_scale_factor = g_page_v_scale_factor = in_scale_factor; g_page_h_origin = g_page_v_origin = 0; g_page_line_width = in_line_width; - g_graphics_vars[k_in] = IN; - g_graphics_vars[k_cm] = CM; - g_graphics_vars[k_pt] = PT; - g_graphics_vars[k_em] = EM; g_graphics_vars[k_xsize] = 0; /* undefined */ g_graphics_vars[k_ysize] = 0; /* undefined */ g_graphics_vars[k_xmark] = 0; /* undefined */ g_graphics_vars[k_ymark] = 0; /* undefined */ - g_graphics_vars[k_loutf] = 0; /* undefined */ - g_graphics_vars[k_loutv] = 0; /* undefined */ - g_graphics_vars[k_louts] = 0; /* undefined */ + /* No need to touch k_in other constant units */ + g_units[k_loutf] = 0; /* undefined */ + g_units[k_loutv] = 0; /* undefined */ + g_units[k_louts] = 0; /* undefined */ + g_ET_pending = FALSE; g_TJ_pending = FALSE; g_valid_text_matrix = FALSE; /* Td is not allowed */ @@ -3201,6 +3189,9 @@ /* write out /Page ID */ fputs("<<\n/Type /Page\n", in_fp); + /* write out page size and orientation */ + fprintf(in_fp, "/CropBox [ 0 0 %u %u ]\n",g_doc_h_bound,g_doc_v_bound); + /* write out parent object ref */ fputs("/Parent ", in_fp); PDFObject_WriteRef(in_fp, g_pages_root); @@ -3388,8 +3379,7 @@ fputs(" ", in_fp); } fprintf(in_fp, " ]\n/Count %u\n", g_page_count); - fprintf(in_fp, "/MediaBox [ 0 0 612 792 ]\n"); - /* fprintf(in_fp, "/MediaBox [ 0 0 %u %u ]\n",g_doc_h_bound,g_doc_v_bound); */ + fprintf(in_fp, "/MediaBox [ 0 0 %u %u ]\n",g_doc_h_bound,g_doc_v_bound); fputs(">>\nendobj\n", in_fp); } Index: doc/user/bas_drop =================================================================== RCS file: /home/uwe/repository/lout/doc/user/bas_drop,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- bas_drop 1999/02/14 15:53:04 1.1.1.1 +++ bas_drop 1999/02/26 15:21:37 1.2 @@ -4,8 +4,8 @@ @Begin @PP There are two symbols for producing drop capitals, address@hidden "@DropCapTwo"} -DropCapTwo.sym @Index @Code "@DropCapTwo" -DropCapThree.sym @Index @Code "@DropCapThree" +drop.cap.two.sym @Index @Code "@DropCapTwo" +drop.cap.three.sym @Index @Code "@DropCapThree" and address@hidden "@DropCapThree"}. Place the capital to be dropped just before the symbol, and the rest of the paragraph after it: @ID @OneRow @Code { Index: doc/user/dia_erro =================================================================== RCS file: /home/uwe/repository/lout/doc/user/dia_erro,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- dia_erro 1999/02/14 15:53:02 1.1.1.1 +++ dia_erro 1999/02/26 15:16:45 1.2 @@ -25,7 +25,7 @@ have been printed next. @PP If you see address@hidden VMerror} in an error message, it means that the printer -VMerror. @Index { @Code VMerror PostScript error } +vmerror. @Index { @Code VMerror PostScript error } is running out of memory. In that case, one thing you can try is @ID @Code { "@Diag"