From 08f37a293bf2ca78b7832676142f97a4e5ebbc67 Mon Sep 17 00:00:00 2001 From: lotherk Date: Sun, 22 Nov 2026 22:01:24 +0000 Subject: [PATCH] MCDE: dtphoto, dtbar, dtsystemsettings, dtwm, icons and thumbnails; recipes follow the host-flag settings Co-Authored-By: Claude Sonnet 5.5 --- ext/src/afpfs-ng/pkgsrc/distinfo | 6 +- ext/src/mcde/configure.ac | 2 +- ext/src/mcde/include/Mcde/Thumb.h | 6 +- ext/src/mcde/lib/DtSvc/DtUtil2/McdeThumb.c | 544 ++- ext/src/mcde/motif/tools/wml/wmlparse.c | 3798 +++++++++++------ ext/src/mcde/motif/tools/wml/wmlparse.h | 132 + ext/src/mcde/motif/tools/wml/wmluiltok.c | 435 +- ext/src/mcde/pkgsrc-motif/Makefile | 22 +- ext/src/mcde/pkgsrc-motif/distinfo | 6 +- ext/src/mcde/pkgsrc/Makefile | 5 +- ext/src/mcde/pkgsrc/distinfo | 6 +- ext/src/mcde/programs/dtbar/dtbar.c | 29 +- ext/src/mcde/programs/dtphoto/dtphoto.c | 3277 +++++++++++++- ext/src/mcde/programs/dtphoto/dtphoto.menu | 1 + .../programs/dtsystemsettings/Makefile.am | 2 +- ext/src/mcde/programs/dtsystemsettings/main.c | 2 + .../mcde/programs/dtsystemsettings/panes.c | 2 + ext/src/mcde/programs/dtsystemsettings/ui.h | 1 + ext/src/mcde/programs/dtwm/UI.c | 29 +- ext/src/mcde/programs/dtwm/WmEvent.c | 28 +- ext/src/mcde/programs/dtwm/WmMcdeDesktop.c | 63 +- ext/src/mcde/programs/dtwm/WmMcdePanel.c | 54 +- ext/src/mcde/programs/icons/IrixCD.m.pm | 98 +- ext/src/mcde/programs/icons/IrixDVD.m.pm | 98 +- ext/src/mcde/programs/icons/IrixDisk.m.pm | 98 +- ext/src/mcde/programs/icons/IrixFloppy.m.pm | 98 +- ext/src/mcde/programs/icons/IrixNet.m.pm | 98 +- ext/src/mcde/programs/icons/IrixTape.m.pm | 98 +- .../localized/de_DE.UTF-8/msg/dtphoto.msg | 2 + 29 files changed, 7169 insertions(+), 1871 deletions(-) diff --git a/ext/src/afpfs-ng/pkgsrc/distinfo b/ext/src/afpfs-ng/pkgsrc/distinfo index 60741b22bb..9ec3480d74 100644 --- a/ext/src/afpfs-ng/pkgsrc/distinfo +++ b/ext/src/afpfs-ng/pkgsrc/distinfo @@ -1,5 +1,5 @@ $NetBSD$ -BLAKE2s (afpfs-ng-0.8.1.tar.gz) = 342df933226a6a81f99199975aa28c220735868488e201bf32a1d13bf8be5142 -SHA512 (afpfs-ng-0.8.1.tar.gz) = 0abcb76e32d11c330eab357a7ab8feeccede68953ed6b8400a282a098c82105476f4b052f8c1b69e96f91a2a22657f9dacc5d35f5a65b72112ecb7addbd94751 -Size (afpfs-ng-0.8.1.tar.gz) = 460185 bytes +BLAKE2s (afpfs-ng-0.8.1.tar.gz) = 618b25240d2e1d483ea25bad52877b1abb01eb05384e1172ba62cac2c51f4a8e +SHA512 (afpfs-ng-0.8.1.tar.gz) = af7d528a8886748dc71a739555cf6fca18d0cd9efb740b260759838b7dce66e1d668d93755e743da816f88ccc7226c48029764e1864c9b3a0262b08bbdc555f8 +Size (afpfs-ng-0.8.1.tar.gz) = 460106 bytes diff --git a/ext/src/mcde/configure.ac b/ext/src/mcde/configure.ac index 20b0e3eeb2..625c454e44 100644 --- a/ext/src/mcde/configure.ac +++ b/ext/src/mcde/configure.ac @@ -74,7 +74,7 @@ if test "$enable_xft" = yes; then fi AC_SUBST(XFTLIB) AC_SUBST(XFT_CFLAGS) -AC_PREFIX_DEFAULT(/usr/dt) +AC_PREFIX_DEFAULT(/usr/mdt) PKG_PROG_PKG_CONFIG diff --git a/ext/src/mcde/include/Mcde/Thumb.h b/ext/src/mcde/include/Mcde/Thumb.h index 9ff13e2080..71824754c8 100644 --- a/ext/src/mcde/include/Mcde/Thumb.h +++ b/ext/src/mcde/include/Mcde/Thumb.h @@ -52,7 +52,11 @@ int McdeThumbScale(const unsigned char *src, int sw, int sh, int maxw, int maxh, unsigned char **dst, int *w, int *h); /* IMAGE (8-bit RGB) written to PATH. The format comes from the name's - * ending: .png and .bmp are written, anything else is refused. A picture + * ending: .png, .bmp, .jpg/.jpeg, .gif and .xpm are written, anything else + * is refused. PNG, BMP and XPM come back exactly; JPEG is lossy by its own + * nature. GIF carries at most 256 colours, so a picture with more than that + * goes through a 6x5x6 cube (largest deviation 25 of 255, measured + * 2026-11-22), while one that fits keeps its own colours exactly. A picture * written here is read back by McdeThumbRead() pixel for pixel, which is * what the test checks. 0 on success, -1 on a bad argument, an unknown * ending or a write error. */ diff --git a/ext/src/mcde/lib/DtSvc/DtUtil2/McdeThumb.c b/ext/src/mcde/lib/DtSvc/DtUtil2/McdeThumb.c index 2126408188..c66232e2f2 100644 --- a/ext/src/mcde/lib/DtSvc/DtUtil2/McdeThumb.c +++ b/ext/src/mcde/lib/DtSvc/DtUtil2/McdeThumb.c @@ -787,7 +787,7 @@ ReadGif(const char *path, unsigned char **rgbp, int *wp, int *hp) } if (kind == 0x2c) { int left, top, iw, ih, ipacked, min_size; - size_t room, used; + size_t room, used, after; if (at + 9 > len) break; @@ -818,23 +818,41 @@ ReadGif(const char *path, unsigned char **rgbp, int *wp, int *hp) min_size = buf[at++]; if (min_size < 2 || min_size > 8) goto bad; - room = (size_t) iw * ih; - if ((data = malloc(room)) == NULL) - goto bad; - used = GifBlocks(buf, len, at, data, room); - /* find where the data ended, to go on after it */ + /* + * The compressed stream is not bounded by the + * pixel count: 8-bit codes need more than one byte + * per pixel and a short stream is padded. The + * buffer has to hold the whole sub-block chain, so + * the chain is measured first. Until 2026-11-22 + * this allocated iw*ih, which was too small for + * every picture that was not mostly a repeat: the + * data was silently cut and GifLzw failed on it + * (measured: a 12x9 GIF with 108 colours, 124 + * compressed bytes in a 108 byte buffer). + */ { size_t p = at; - while (p < len && buf[p] != 0) + room = 0; + while (p < len && buf[p] != 0) { + size_t n = buf[p]; + + if (p + 1 + n > len) + n = len - p - 1; + room += n; p += buf[p] + 1; - at = p < len ? p + 1 : len; + } + after = p < len ? p + 1 : len; } - if ((out = malloc(room)) == NULL) + if (room == 0 || (data = malloc(room)) == NULL) + goto bad; + used = GifBlocks(buf, len, at, data, room); + at = after; + if ((out = malloc((size_t) iw * ih)) == NULL) goto bad; { int n = GifLzw(data, used, min_size, out, - (long) room); + (long) iw * ih); if (n < 0) goto bad; @@ -1659,6 +1677,506 @@ WriteBmp(const char *path, const unsigned char *rgb, int w, int h) return fclose(fp) == 0 ? 0 : -1; } +/* + * A JPEG, as the decoder reads it: libjpeg's compressor, 4:4:4 so that a + * small picture keeps its colours instead of being smeared by chroma + * subsampling. Quality 92 is a photograph setting, not a thumbnail one. + */ +static int +WriteJpeg(const char *path, const unsigned char *rgb, int w, int h) +{ + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; + FILE *fp; + unsigned char *row; + int y; + + if ((fp = fopen(path, "wb")) == NULL) + return -1; + if ((row = malloc((size_t) w * 3)) == NULL) { + fclose(fp); + return -1; + } + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + jpeg_stdio_dest(&cinfo, fp); + cinfo.image_width = (JDIMENSION) w; + cinfo.image_height = (JDIMENSION) h; + cinfo.input_components = 3; + cinfo.in_color_space = JCS_RGB; + jpeg_set_defaults(&cinfo); + jpeg_set_quality(&cinfo, 92, TRUE); + /* 4:4:4: a small picture must not lose its colours */ + cinfo.comp_info[0].h_samp_factor = 1; + cinfo.comp_info[0].v_samp_factor = 1; + jpeg_start_compress(&cinfo, TRUE); + while (cinfo.next_scanline < cinfo.image_height) { + JSAMPROW r = row; + + y = (int) cinfo.next_scanline; + memcpy(row, rgb + (size_t) y * (size_t) w * 3, + (size_t) w * 3); + jpeg_write_scanlines(&cinfo, &r, 1); + } + jpeg_finish_compress(&cinfo); + jpeg_destroy_compress(&cinfo); + free(row); + return fclose(fp) == 0 ? 0 : -1; +} + +/* the colour cube a GIF and an XPM share: 6 x 7 x 6 = 252 entries */ +#define CUBE_R 6 +#define CUBE_G 7 +#define CUBE_B 6 +#define CUBE_N (CUBE_R * CUBE_G * CUBE_B) + +/* + * The picture's own colours as a GIF table, when there are no more than + * 256 of them. Writes the palette and the pixel indices, and returns the + * count, or 0 when the picture has too many colours for this to be exact. + */ +static int +ExactPalette(const unsigned char *rgb, int w, int h, + unsigned char *pal, unsigned char *idx) +{ + /* + * A hash of the colours seen so far. Open addressing over 1024 + * slots: the table is at most half full, so a probe chain stays + * short without any deleting. + */ + static int seen[1024]; + int used = 1024; + int n = 0, i, p; + + for (i = 0; i < 1024; i++) + seen[i] = -1; + for (i = 0; i < w * h; i++) { + const unsigned char *s = rgb + (size_t) i * 3; + unsigned long key = ((unsigned long) s[0] << 16) | + ((unsigned long) s[1] << 8) | s[2]; + unsigned long slot = (key * 2654435761UL) & 1023; + + for (;;) { + if (seen[slot] == -1) { + if (n == 256) + return 0; + seen[slot] = n; + pal[n * 3] = s[0]; + pal[n * 3 + 1] = s[1]; + pal[n * 3 + 2] = s[2]; + idx[i] = (unsigned char) n; + n++; + break; + } + if (pal[seen[slot] * 3] == s[0] && + pal[seen[slot] * 3 + 1] == s[1] && + pal[seen[slot] * 3 + 2] == s[2]) { + idx[i] = (unsigned char) seen[slot]; + break; + } + slot = (slot + 1) & 1023; + } + } + /* + * The unused cells stay black: the encoder always writes the full + * 256 entries, so the file says what the indices mean even where + * no pixel uses them. + */ + for (p = n; p < 256; p++) + pal[p * 3] = pal[p * 3 + 1] = pal[p * 3 + 2] = 0; + return n; +} + +static int +CubeIndex(const unsigned char *s) +{ + int r = (s[0] * (CUBE_R - 1) + 127) / 255; + int g = (s[1] * (CUBE_G - 1) + 127) / 255; + int b = (s[2] * (CUBE_B - 1) + 127) / 255; + + return (r * CUBE_G + g) * CUBE_B + b; +} + +static void +CubePalette(unsigned char *pal) +{ + int i, r, g, b, k = 0; + + memset(pal, 0, 256 * 3); + for (r = 0; r < CUBE_R; r++) + for (g = 0; g < CUBE_G; g++) + for (b = 0; b < CUBE_B; b++) { + pal[k * 3] = (unsigned char) + (r * 255 / (CUBE_R - 1)); + pal[k * 3 + 1] = (unsigned char) + (g * 255 / (CUBE_G - 1)); + pal[k * 3 + 2] = (unsigned char) + (b * 255 / (CUBE_B - 1)); + k++; + } + for (i = k; i < 256; i++) + pal[i * 3] = pal[i * 3 + 1] = pal[i * 3 + 2] = 0; +} + +/* + * A GIF87a with a global colour table of the cube above. GIF carries at + * most 256 colours, so a 24-bit picture has to be reduced to be a GIF at + * all; 6x7x6 is the cube an 8-bit desktop could show. The LZW is the + * format's own compressor, with the hash table the reference uses so that + * the cost per pixel stays constant. + */ +static int +WriteGif(const char *path, const unsigned char *rgb, int w, int h) +{ + FILE *fp; + unsigned char *idx, pal[256 * 3]; + unsigned char hdr[7], desc[10]; + int x, y, k; + + if (w > 65535 || h > 65535) + return -1; + if ((fp = fopen(path, "wb")) == NULL) + return -1; + if ((idx = malloc((size_t) w * h)) == NULL) { + fclose(fp); + return -1; + } + /* + * A picture with at most 256 distinct colours needs no quantisation + * at all: its own colours become the table, and every pixel keeps + * its exact value. The cube below is the fallback for everything + * else. Measured 2026-11-22: a 16x12 test picture came back with a + * delta of 8 through the cube, 0 through the exact table. + */ + if (ExactPalette(rgb, w, h, pal, idx) <= 0) { + /* + * More colours than a table holds: the fixed cube decides + * both the table and every pixel's index. (This step went + * missing once and the file carried an untouched index + * buffer -- measured: a 64x64 picture lost 90% of its + * raster.) + */ + CubePalette(pal); + for (y = 0; y < h; y++) + for (x = 0; x < w; x++) + idx[(size_t) y * w + x] = (unsigned char) + CubeIndex(rgb + + ((size_t) y * w + x) * 3); + } + fputs("GIF87a", fp); + hdr[0] = (unsigned char) (w & 0xFF); + hdr[1] = (unsigned char) ((w >> 8) & 0xFF); + hdr[2] = (unsigned char) (h & 0xFF); + hdr[3] = (unsigned char) ((h >> 8) & 0xFF); + hdr[4] = (unsigned char) (0x80 | 0x70 | 7); /* table, 8 bits */ + hdr[5] = 0; /* background */ + hdr[6] = 0; /* aspect */ + if (fwrite(hdr, 1, sizeof hdr, fp) != sizeof hdr) + goto bad; + if (fwrite(pal, 1, sizeof pal, fp) != sizeof pal) + goto bad; + desc[0] = 0x2C; /* image descriptor */ + desc[1] = desc[2] = desc[3] = desc[4] = 0; /* left, top */ + desc[5] = (unsigned char) (w & 0xFF); + desc[6] = (unsigned char) ((w >> 8) & 0xFF); + desc[7] = (unsigned char) (h & 0xFF); + desc[8] = (unsigned char) ((h >> 8) & 0xFF); + desc[9] = 0; /* no local table */ + if (fwrite(desc, 1, sizeof desc, fp) != sizeof desc) + goto bad; + if (fputc(8, fp) == EOF) /* LZW minimum code size */ + goto bad; + { + /* + * The dictionary: prefix chains in a hash table of the + * reference encoder, so a lookup is one probe and not a walk + * over 4096 entries for every pixel. + */ + static const int HASH_SIZE = 5003; + int *hashTab, *codetab; + unsigned char *out; + size_t outn = 0, outcap; + int next = 258, codeSize = 9, prev = -1; + long bitbuf = 0; + int nbits = 0; + int shift; + + /* + * Worst case: one 12-bit code per pixel plus the clear and + * end codes, so 2 bytes per pixel is ample. The old bound + * (w*h + 1024) silently truncated a 1024x768 picture and + * the file came out empty (measured 2026-11-22). + */ + outcap = (size_t) w * h * 2 + 4096; + hashTab = malloc(sizeof(int) * HASH_SIZE); + codetab = malloc(sizeof(int) * HASH_SIZE); + out = malloc(outcap); + if (hashTab == NULL || codetab == NULL || out == NULL) { + free(hashTab); + free(codetab); + free(out); + goto bad; + } + for (k = 0; k < HASH_SIZE; k++) + hashTab[k] = -1; + +#define GPIOUT(c) do { \ + bitbuf |= (long) (c) << nbits; \ + nbits += codeSize; \ + while (nbits >= 8) { \ + if (outn >= outcap) { \ + free(out); \ + free(hashTab); \ + free(codetab); \ + goto bad; \ + } \ + out[outn++] = (unsigned char) (bitbuf & 0xFF); \ + bitbuf >>= 8; \ + nbits -= 8; \ + } \ +} while (0) + GPIOUT(256); /* clear */ + for (y = 0; y < h; y++) + for (x = 0; x < w; x++) { + int c = idx[(size_t) y * w + x]; + + if (prev < 0) { + prev = c; + continue; + } + /* (prev, c) already in the table? */ + { + long fcode = (long) prev * 256 + c; + int i = (int) ((fcode >> 12) ^ + (fcode & 0xFFF)); + + if (i >= HASH_SIZE) + i -= HASH_SIZE; + /* + * The step must not be a multiple of + * the table size, or the probe keeps + * landing on the same slot. At i = 0 + * the step was exactly HASH_SIZE and + * the encoder never returned (measured + * 2026-11-22: a 128x128 picture hung on + * the first colour pair whose hash + * collapsed to slot 0). + */ + if (i <= 0) { + i = 0; + shift = 1; + } else + shift = HASH_SIZE - i; + for (;;) { + if (hashTab[i] < 0) + break; + if (hashTab[i] == fcode) { + prev = codetab[i]; + goto have; + } + i -= shift; + if (i < 0) + i += HASH_SIZE; + } + /* not there: emit and add it */ + GPIOUT(prev); + if (next < 4096) { + codetab[i] = next; + hashTab[i] = (int) fcode; + next++; + /* + * The width goes up only + * after the code that + * filled the range: the + * reader adds its entry for + * the *previous* code, so it + * is always one behind. + * `>=` here desynchronised + * every reader from code 512 + * on (checked against + * giftopnm 2026-11-22: the + * `>` rule decodes, `>=` + * does not). + */ + if (next > (1 << codeSize) && + codeSize < 12) + codeSize++; + } else { + GPIOUT(256); + next = 258; + codeSize = 9; + for (k = 0; k < HASH_SIZE; k++) + hashTab[k] = -1; + } + prev = c; + } +have: + ; + } + if (prev >= 0) + GPIOUT(prev); + GPIOUT(257); /* end of information */ + if (nbits > 0) { + if (outn >= outcap) { + free(out); + free(hashTab); + free(codetab); + goto bad; + } + out[outn++] = (unsigned char) (bitbuf & 0xFF); + } +#undef GPIOUT + /* data in blocks of at most 255 bytes, a zero byte ends it */ + { + size_t p = 0; + + while (p < outn) { + size_t n = outn - p; + + if (n > 255) + n = 255; + if (fputc((int) n, fp) == EOF || + fwrite(out + p, 1, n, fp) != n) { + free(out); + free(hashTab); + free(codetab); + goto bad; + } + p += n; + } + } + free(out); + free(hashTab); + free(codetab); + } + if (fputc(0, fp) == EOF || fputc(';', fp) == EOF) + goto bad; + free(idx); + return fclose(fp) == 0 ? 0 : -1; +bad: + free(idx); + fclose(fp); + return -1; +} + +/* + * An XPM3. The colour table comes from the colours the picture actually + * has while they fit in 256, so a flat picture keeps its exact values; a + * photographic one is reduced to the same cube the GIF writer uses. The + * codes come from the 92 printable characters, one per colour while they + * fit and two after that. + */ +static int +WriteXpm(const char *path, const unsigned char *rgb, int w, int h) +{ + /* + * Every printable ASCII character except '"' and '\\', which + * cannot appear in an XPM key without escaping, and the space, + * which leads. 93 distinct keys, so two-character keys work up + * to 93 * 93 = 8649 colours. The table held the duplicates 'X', + * 'o' and 'O' twice until 2026-11-22: from 93 colours on, two + * palette entries got the same key and the picture read back + * wrong (measured: 12x9 with 108 colours, 9 bytes off). + */ + static const char chars[] = + " !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "[]^_`abcdefghijklmnopqrstuvwxyz{|}~"; + FILE *fp; + unsigned long key[256]; + unsigned char pal[256 * 3]; + int nkey = 0, i, x, y, cpp, cap = (int) (sizeof chars - 1); + int *idx; + int useCube = 0; + + if ((fp = fopen(path, "wb")) == NULL) + return -1; + idx = malloc(sizeof(int) * (size_t) w * h); + if (idx == NULL) { + fclose(fp); + return -1; + } + /* + * A flat picture keeps its exact colours: the first pass collects + * them while they fit in 256. A photographic one cannot, and is + * reduced to the cube the GIF writer uses, so the two agree. + */ + for (y = 0; y < h && !useCube; y++) + for (x = 0; x < w; x++) { + const unsigned char *s = + rgb + ((size_t) y * w + x) * 3; + unsigned long k = ((unsigned long) s[0] << 16) | + ((unsigned long) s[1] << 8) | s[2]; + + for (i = 0; i < nkey; i++) + if (key[i] == k) + break; + if (i == nkey) { + if (nkey == 256) { + useCube = 1; + break; + } + key[nkey] = k; + pal[nkey * 3] = s[0]; + pal[nkey * 3 + 1] = s[1]; + pal[nkey * 3 + 2] = s[2]; + nkey++; + } + } + if (useCube) { + CubePalette(pal); + nkey = CUBE_N; + } + for (y = 0; y < h; y++) + for (x = 0; x < w; x++) { + const unsigned char *s = + rgb + ((size_t) y * w + x) * 3; + + if (useCube) { + idx[(size_t) y * w + x] = CubeIndex(s); + } else { + unsigned long k = + ((unsigned long) s[0] << 16) | + ((unsigned long) s[1] << 8) | s[2]; + + for (i = 0; i < nkey; i++) + if (key[i] == k) + break; + idx[(size_t) y * w + x] = i < nkey ? i : 0; + } + } + cpp = nkey > cap ? 2 : 1; + fprintf(fp, "/* XPM */\nstatic char *picture_xpm[] = {\n"); + fprintf(fp, "\"%d %d %d %d\",\n", w, h, nkey, cpp); + for (i = 0; i < nkey; i++) { + if (cpp == 1) + fprintf(fp, "\"%c c #%02X%02X%02X\",\n", + chars[i % cap], pal[i * 3], pal[i * 3 + 1], + pal[i * 3 + 2]); + else + fprintf(fp, "\"%c%c c #%02X%02X%02X\",\n", + chars[(i / cap) % cap], chars[i % cap], + pal[i * 3], pal[i * 3 + 1], pal[i * 3 + 2]); + } + for (y = 0; y < h; y++) { + fputc('"', fp); + for (x = 0; x < w; x++) { + int v = idx[(size_t) y * w + x]; + + if (cpp == 1) { + fputc(chars[v % cap], fp); + } else { + fputc(chars[(v / cap) % cap], fp); + fputc(chars[v % cap], fp); + } + } + fputc('"', fp); + fputs(y == h - 1 ? "\n" : ",\n", fp); + } + fputs("};\n", fp); + free(idx); + return fclose(fp) == 0 ? 0 : -1; +} + int McdeThumbWrite(const char *path, const unsigned char *rgb, int w, int h) { @@ -1670,5 +2188,11 @@ McdeThumbWrite(const char *path, const unsigned char *rgb, int w, int h) return WritePng(path, rgb, w, h); if (SameEnding(path, "bmp")) return WriteBmp(path, rgb, w, h); + if (SameEnding(path, "jpg") || SameEnding(path, "jpeg")) + return WriteJpeg(path, rgb, w, h); + if (SameEnding(path, "gif")) + return WriteGif(path, rgb, w, h); + if (SameEnding(path, "xpm")) + return WriteXpm(path, rgb, w, h); return -1; } diff --git a/ext/src/mcde/motif/tools/wml/wmlparse.c b/ext/src/mcde/motif/tools/wml/wmlparse.c index bb0a5608ae..4167d7347a 100644 --- a/ext/src/mcde/motif/tools/wml/wmlparse.c +++ b/ext/src/mcde/motif/tools/wml/wmlparse.c @@ -1,26 +1,85 @@ -/* original parser id follows */ -/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ -/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ +/* A Bison parser, made by GNU Bison 3.8.2. */ -#define YYBYACC 1 -#define YYMAJOR 1 -#define YYMINOR 9 -#define YYPATCH 20140715 +/* Bison implementation for Yacc-like parsers in C -#define YYEMPTY (-1) -#define yyclearin (yychar = YYEMPTY) -#define yyerrok (yyerrflag = 0) -#define YYRECOVERING() (yyerrflag != 0) -#define YYENOMEM (-2) -#define YYEOF 0 -#define YYPREFIX "yy" + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, + Inc. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output, and Bison version. */ +#define YYBISON 30802 + +/* Bison version string. */ +#define YYBISON_VERSION "3.8.2" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ #define YYPURE 0 -#line 35 "wmlparse.y" +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + + + + +/* First part of user prologue. */ +#line 34 "wmlparse.y" + #include "wml.h" +/* + * The generated parser calls these two, which are defined in wmllex.c (flex) + * and Uil.c; GCC 14 and later refuse an implicit declaration in C99 and later, + * where these 1990s sources only got a warning. + */ +extern int yylex (void); +extern int yyerror (char *); + #if defined(__STDC__) #include /* for strcpy() */ #endif @@ -40,45 +99,111 @@ #undef NULL #endif -#line 44 "wmlparse.c" -#if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) -/* Default: YYSTYPE is the semantic value type. */ -typedef int YYSTYPE; -# define YYSTYPE_IS_DECLARED 1 -#endif +#line 104 "wmlparse.c" -/* compatibility with bison */ -#ifdef YYPARSE_PARAM -/* compatibility with FreeBSD */ -# ifdef YYPARSE_PARAM_TYPE -# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) -# else -# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) +# ifndef YY_CAST +# ifdef __cplusplus +# define YY_CAST(Type, Val) static_cast (Val) +# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val) +# else +# define YY_CAST(Type, Val) ((Type) (Val)) +# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) +# endif # endif -#else -# define YYPARSE_DECL() yyparse(void) +# ifndef YY_NULLPTR +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# else +# define YY_NULLPTR ((void*)0) +# endif +# endif + +/* Use api.header.include to #include this header + instead of duplicating it here. */ +#ifndef YY_YY_WMLPARSE_H_INCLUDED +# define YY_YY_WMLPARSE_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; #endif -/* Parameters sent to lex. */ -#ifdef YYLEX_PARAM -# define YYLEX_DECL() yylex(void *YYLEX_PARAM) -# define YYLEX yylex(YYLEX_PARAM) -#else -# define YYLEX_DECL() yylex(void) -# define YYLEX yylex() +/* Token kinds. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + YYEMPTY = -2, + YYEOF = 0, /* "end of file" */ + YYerror = 256, /* error */ + YYUNDEF = 257, /* "invalid token" */ + CLASS = 1, /* CLASS */ + RESOURCE = 2, /* RESOURCE */ + DATATYPE = 3, /* DATATYPE */ + CONTROLLIST = 4, /* CONTROLLIST */ + ENUMERATIONSET = 5, /* ENUMERATIONSET */ + ENUMERATIONVALUE = 6, /* ENUMERATIONVALUE */ + CHARACTERSET = 7, /* CHARACTERSET */ + CHILD = 50, /* CHILD */ + DOCNAME = 8, /* DOCNAME */ + CONVFUNC = 9, /* CONVFUNC */ + ALIAS = 10, /* ALIAS */ + TYPE = 11, /* TYPE */ + RESOURCELITERAL = 12, /* RESOURCELITERAL */ + RELATED = 13, /* RELATED */ + INTERNALLITERAL = 14, /* INTERNALLITERAL */ + XRMRESOURCE = 15, /* XRMRESOURCE */ + EXCLUDE = 16, /* EXCLUDE */ + RESOURCES = 17, /* RESOURCES */ + SUPERCLASS = 18, /* SUPERCLASS */ + CONTROLS = 19, /* CONTROLS */ + WIDGETCLASS = 20, /* WIDGETCLASS */ + DIALOGCLASS = 21, /* DIALOGCLASS */ + DEFAULT = 22, /* DEFAULT */ + ENUMLITERAL = 23, /* ENUMLITERAL */ + XMSTRINGCHARSETNAME = 24, /* XMSTRINGCHARSETNAME */ + DIRECTION = 25, /* DIRECTION */ + PARSEDIRECTION = 26, /* PARSEDIRECTION */ + CHARACTERSIZE = 27, /* CHARACTERSIZE */ + CTRLMAPSRESOURCE = 28, /* CTRLMAPSRESOURCE */ + CHILDREN = 51, /* CHILDREN */ + PARENTCLASS = 52, /* PARENTCLASS */ + METACLASS = 29, /* METACLASS */ + WIDGET = 30, /* WIDGET */ + GADGET = 31, /* GADGET */ + ARGUMENT = 32, /* ARGUMENT */ + REASON = 33, /* REASON */ + CONSTRAINT = 34, /* CONSTRAINT */ + SUBRESOURCE = 35, /* SUBRESOURCE */ + ATTRTRUE = 36, /* ATTRTRUE */ + ATTRFALSE = 37, /* ATTRFALSE */ + LEFTTORIGHT = 38, /* LEFTTORIGHT */ + RIGHTTOLEFT = 39, /* RIGHTTOLEFT */ + ONEBYTE = 40, /* ONEBYTE */ + TWOBYTE = 41, /* TWOBYTE */ + MIXED1_2BYTE = 42, /* MIXED1_2BYTE */ + COLON = 43, /* COLON */ + SEMICOLON = 44, /* SEMICOLON */ + EQUALS = 45, /* EQUALS */ + LBRACE = 46, /* LBRACE */ + RBRACE = 47, /* RBRACE */ + STRING = 48, /* STRING */ + ERRORTOKEN = 49 /* ERRORTOKEN */ + }; + typedef enum yytokentype yytoken_kind_t; #endif - -/* Parameters sent to yyerror. */ -#ifndef YYERROR_DECL -#define YYERROR_DECL() yyerror(const char *s) -#endif -#ifndef YYERROR_CALL -#define YYERROR_CALL(msg) yyerror(msg) -#endif - -extern int YYPARSE_DECL(); - +/* Token kinds. */ +#define YYEMPTY -2 +#define YYEOF 0 +#define YYerror 256 +#define YYUNDEF 257 #define CLASS 1 #define RESOURCE 2 #define DATATYPE 3 @@ -131,646 +256,2295 @@ extern int YYPARSE_DECL(); #define RBRACE 47 #define STRING 48 #define ERRORTOKEN 49 -#define YYERRCODE 256 -typedef short YYINT; -static const YYINT yylhs[] = { -1, - 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 10, 1, 2, 11, 11, 13, 11, 3, 14, 14, - 16, 14, 4, 17, 17, 19, 17, 5, 20, 20, - 22, 20, 6, 23, 23, 25, 23, 7, 26, 26, - 28, 26, 8, 29, 29, 31, 29, 9, 32, 32, - 34, 32, 38, 12, 36, 36, 36, 37, 37, 37, - 40, 37, 39, 39, 43, 41, 46, 41, 41, 41, - 41, 50, 41, 42, 42, 42, 42, 42, 42, 42, - 42, 44, 45, 45, 47, 51, 51, 51, 53, 51, - 52, 52, 56, 54, 57, 54, 55, 55, 55, 59, - 55, 58, 58, 62, 60, 64, 60, 65, 60, 61, - 61, 63, 48, 66, 66, 66, 68, 66, 67, 67, - 71, 69, 72, 69, 70, 70, 73, 70, 49, 74, - 74, 74, 76, 74, 75, 75, 78, 77, 79, 77, - 82, 15, 80, 80, 80, 80, 81, 81, 81, 84, - 81, 83, 83, 87, 85, 89, 85, 90, 85, 86, - 86, 86, 86, 86, 86, 86, 86, 88, 18, 92, - 21, 91, 91, 91, 94, 91, 93, 93, 97, 95, - 98, 95, 96, 96, 96, 100, 24, 99, 99, 99, - 102, 99, 101, 101, 105, 103, 106, 103, 104, 104, - 107, 104, 110, 27, 108, 109, 109, 109, 112, 109, - 111, 111, 114, 113, 115, 113, 117, 30, 116, 116, - 116, 119, 116, 118, 118, 122, 120, 123, 120, 121, - 125, 33, 124, 124, 124, 127, 124, 126, 126, 130, - 128, 133, 128, 134, 128, 129, 129, 129, 131, 131, - 131, 132, 132, 132, 132, 132, 35, -}; -static const YYINT yylen[] = { 2, - 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 3, 2, 2, 3, 0, 3, 2, 2, 3, - 0, 3, 2, 2, 3, 0, 3, 2, 2, 3, - 0, 3, 2, 2, 3, 0, 3, 2, 2, 3, - 0, 3, 2, 2, 3, 0, 3, 2, 2, 3, - 0, 3, 0, 5, 1, 1, 1, 0, 2, 3, - 0, 3, 1, 2, 0, 5, 0, 5, 2, 2, - 2, 0, 3, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 2, 0, 2, 3, 0, 3, - 1, 2, 0, 4, 0, 3, 0, 2, 3, 0, - 3, 1, 2, 0, 5, 0, 5, 0, 3, 1, - 1, 1, 2, 0, 2, 3, 0, 3, 1, 2, - 0, 4, 0, 3, 0, 2, 0, 3, 2, 0, - 2, 3, 0, 3, 1, 2, 0, 3, 0, 3, - 0, 5, 1, 1, 1, 1, 0, 2, 3, 0, - 3, 1, 2, 0, 5, 0, 5, 0, 3, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 3, 0, - 3, 0, 2, 3, 0, 3, 1, 2, 0, 5, - 0, 3, 1, 1, 1, 0, 3, 0, 2, 3, - 0, 3, 1, 2, 0, 4, 0, 3, 0, 2, - 0, 3, 0, 5, 1, 0, 2, 3, 0, 3, - 1, 2, 0, 3, 0, 3, 0, 4, 0, 2, - 3, 0, 3, 1, 2, 0, 5, 0, 3, 1, - 0, 3, 0, 2, 3, 0, 3, 1, 2, 0, - 5, 0, 5, 0, 3, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, -}; -static const YYINT yydefred[] = { 1, - 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, - 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, - 16, 257, 0, 0, 0, 21, 0, 0, 0, 31, - 0, 0, 170, 36, 0, 0, 186, 41, 0, 0, - 0, 46, 0, 0, 0, 51, 0, 0, 231, 26, - 0, 0, 0, 12, 0, 0, 14, 0, 0, 0, - 19, 0, 0, 0, 29, 0, 0, 0, 34, 0, - 0, 0, 39, 0, 0, 0, 44, 217, 0, 0, - 49, 0, 0, 0, 24, 0, 17, 15, 55, 56, - 57, 53, 22, 20, 143, 144, 145, 146, 141, 32, - 30, 175, 0, 171, 37, 35, 191, 0, 187, 42, - 40, 205, 203, 47, 45, 0, 52, 50, 236, 0, - 232, 27, 25, 169, 0, 0, 0, 181, 184, 183, - 185, 173, 0, 177, 0, 0, 197, 189, 195, 0, - 193, 0, 222, 0, 218, 0, 244, 247, 246, 248, - 249, 250, 251, 234, 0, 238, 0, 0, 61, 0, - 54, 150, 0, 142, 176, 0, 174, 178, 0, 192, - 0, 0, 190, 194, 209, 0, 204, 0, 228, 230, - 220, 0, 224, 0, 237, 0, 235, 239, 0, 0, - 0, 72, 77, 78, 81, 76, 0, 74, 0, 79, - 82, 80, 0, 75, 59, 0, 63, 0, 0, 0, - 0, 0, 0, 158, 162, 165, 167, 160, 161, 164, - 163, 168, 166, 148, 0, 152, 0, 0, 182, 179, - 198, 201, 0, 0, 0, 215, 207, 213, 0, 211, - 223, 0, 221, 225, 0, 245, 240, 252, 253, 254, - 255, 256, 242, 62, 0, 89, 0, 85, 117, 0, - 113, 133, 0, 129, 60, 64, 0, 0, 69, 70, - 71, 151, 0, 149, 153, 0, 0, 0, 0, 200, - 196, 210, 0, 0, 208, 212, 229, 226, 0, 0, - 73, 0, 95, 87, 93, 0, 91, 0, 123, 115, - 121, 0, 119, 0, 139, 131, 137, 0, 135, 65, - 83, 84, 67, 159, 154, 156, 180, 202, 216, 214, - 0, 241, 243, 90, 0, 0, 88, 92, 118, 0, - 0, 116, 120, 134, 0, 0, 132, 136, 0, 0, - 0, 0, 227, 96, 100, 0, 0, 124, 127, 0, - 0, 140, 138, 66, 68, 155, 157, 0, 108, 110, - 112, 111, 98, 0, 102, 0, 0, 94, 0, 126, - 122, 101, 0, 99, 103, 0, 0, 128, 109, 104, - 106, 0, 0, 105, 107, -}; -static const YYINT yydgoto[] = { 1, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 23, 24, 55, 27, 28, 59, 51, 52, 83, 31, - 32, 63, 35, 36, 67, 39, 40, 71, 43, 44, - 75, 47, 48, 79, 25, 92, 161, 125, 206, 191, - 207, 208, 339, 209, 313, 340, 210, 211, 212, 255, - 258, 296, 292, 297, 347, 326, 325, 364, 358, 365, - 366, 382, 367, 383, 373, 261, 302, 298, 303, 351, - 331, 330, 369, 264, 308, 304, 309, 336, 335, 99, - 164, 126, 225, 213, 226, 227, 341, 228, 342, 273, - 104, 66, 133, 127, 134, 135, 278, 166, 109, 70, - 140, 136, 141, 234, 172, 171, 279, 113, 177, 142, - 239, 235, 240, 284, 283, 145, 116, 182, 178, 183, - 184, 321, 242, 121, 82, 155, 146, 156, 157, 289, - 158, 253, 290, 186, -}; -static const YYINT yysindex[] = { 0, - 116, 0, -22, -16, 12, 53, 65, 81, 87, 93, - 0, 0, 0, 0, 0, 0, 0, 0, 0, -11, - 0, 0, -20, 2, 100, 0, -20, 108, 110, 0, - -20, 114, 0, 0, -20, 121, 0, 0, -20, 156, - 169, 0, -20, 175, 170, 0, -20, 184, 0, 0, - -20, 185, 190, 0, 188, 202, 0, 193, 205, 208, - 0, 248, 214, 216, 0, -17, 218, 221, 0, -9, - 222, 240, 0, 213, 241, 242, 0, 0, 243, 244, - 0, -8, 245, 246, 0, 247, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 123, 0, 0, 0, 0, 55, 0, 0, - 0, 0, 0, 0, 0, -6, 0, 0, 0, 191, - 0, 0, 0, 0, -5, -2, 249, 0, 0, 0, - 0, 0, 189, 0, -3, 250, 0, 0, 0, 67, - 0, -1, 0, 1, 0, 252, 0, 0, 0, 0, - 0, 0, 0, 0, 217, 0, 192, 255, 0, 159, - 0, 0, 134, 0, 0, 257, 0, 0, 254, 0, - 259, 13, 0, 0, 0, 78, 0, 260, 0, 0, - 0, 11, 0, 261, 0, 268, 0, 0, 265, 237, - 267, 0, 0, 0, 0, 0, 16, 0, 17, 0, - 0, 0, 18, 0, 0, 174, 0, 270, 271, 273, - 274, 275, 277, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 149, 0, 280, 281, 0, 0, - 0, 0, 282, 276, 284, 0, 0, 0, 80, 0, - 0, 283, 0, 0, 285, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 288, 0, 86, 0, 0, 103, - 0, 0, 127, 0, 0, 0, 287, 171, 0, 0, - 0, 0, 295, 0, 0, 292, 171, 297, 298, 0, - 0, 0, 300, 303, 0, 0, 0, 0, 304, 306, - 0, 305, 0, 0, 0, 138, 0, 307, 0, 0, - 0, 142, 0, 308, 0, 0, 0, 151, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 309, 0, 0, 0, 312, 52, 0, 0, 0, 313, - 54, 0, 0, 0, 314, 316, 0, 0, 318, 319, - 320, 321, 0, 0, 0, 14, 322, 0, 0, 323, - 324, 0, 0, 0, 0, 0, 0, 326, 0, 0, - 0, 0, 0, 198, 0, 329, 330, 0, 331, 0, - 0, 0, 325, 0, 0, 328, 171, 0, 0, 0, - 0, 327, 333, 0, 0, -}; -static const YYINT yyrindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 7, 0, 0, 0, 15, 0, 0, 0, - 49, 0, 0, 0, 66, 0, 0, 0, 74, 0, - 0, 0, 82, 0, 0, 0, 90, 0, 0, 0, - 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 336, 0, 0, 0, 337, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 338, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 340, 0, 0, 0, 0, - 0, 0, 0, 0, 341, 342, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 343, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 344, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 345, 0, 241, 0, - 0, 0, 347, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 348, 0, 0, 0, 0, - 349, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -}; -static const YYINT yygindex[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 372, 0, 0, 264, 0, 0, 346, 0, 0, - 262, 0, 0, 293, 0, 0, 357, 0, 0, 251, - 0, 0, 352, 0, -4, 0, 0, 0, 0, 0, - 145, 0, 0, 0, -147, 0, 0, 0, 0, 0, - 0, 0, 0, 71, 0, 0, 0, 0, 0, 36, - 0, 0, 0, 0, 0, 0, 0, 0, 99, 0, - 0, 0, 0, 0, 0, 0, 94, 0, 0, 0, - 0, 0, 0, 0, 178, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 278, 0, 0, 0, 0, 0, - 0, 0, 266, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 165, 0, 0, 0, 0, 0, 0, 226, - 0, 0, 0, 0, 0, 0, 0, 258, 0, 0, - 0, 0, 0, 0, -}; -#define YYTABLESIZE 473 -static const YYINT yytable[] = { 29, - 33, 37, 41, 45, 49, 53, 13, 13, 13, 13, - 13, 13, 13, 13, 18, 18, 18, 18, 18, 18, - 18, 18, 29, 180, 360, 22, 33, 22, 103, 361, - 37, 22, 54, 180, 41, 362, 108, 120, 45, 144, - 160, 169, 49, 163, 176, 57, 53, 181, 28, 28, - 28, 28, 28, 28, 28, 28, 13, 243, 233, 22, - 363, 257, 260, 263, 18, 33, 33, 33, 33, 33, - 33, 33, 33, 38, 38, 38, 38, 38, 38, 38, - 38, 43, 43, 43, 43, 43, 43, 43, 43, 48, - 48, 48, 48, 48, 48, 48, 48, 346, 28, 350, - 22, 138, 22, 139, 23, 23, 23, 23, 23, 23, - 23, 23, 22, 173, 22, 33, 3, 4, 5, 6, - 7, 8, 9, 38, 237, 22, 285, 22, 22, 316, - 129, 43, 294, 22, 22, 139, 130, 131, 215, 48, - 22, 216, 58, 217, 218, 219, 220, 221, 222, 300, - 22, 61, 62, 215, 23, 223, 216, 65, 217, 218, - 219, 220, 221, 222, 69, 10, 193, 194, 195, 132, - 223, 238, 196, 306, 22, 197, 198, 199, 200, 201, - 224, 193, 194, 195, 327, 22, 202, 196, 332, 22, - 197, 198, 199, 200, 201, 274, 129, 337, 22, 73, - 148, 202, 130, 131, 149, 205, 311, 312, 360, 203, - 204, 74, 78, 361, 150, 151, 152, 153, 77, 362, - 265, 89, 90, 91, 203, 204, 148, 81, 85, 381, - 149, 87, 86, 21, 238, 167, 189, 154, 102, 26, - 150, 151, 152, 153, 374, 88, 107, 119, 93, 143, - 159, 94, 295, 162, 175, 301, 179, 100, 307, 101, - 112, 105, 13, 187, 106, 110, 179, 30, 232, 359, - 18, 256, 259, 262, 248, 249, 250, 251, 252, 95, - 96, 97, 98, 111, 114, 115, 117, 118, 122, 123, - 60, 295, 64, 76, 124, 165, 170, 301, 185, 190, - 229, 230, 231, 307, 28, 245, 241, 345, 34, 349, - 137, 246, 247, 254, 267, 268, 269, 270, 271, 281, - 38, 33, 137, 272, 276, 277, 287, 68, 280, 38, - 282, 291, 288, 236, 310, 236, 42, 43, 314, 315, - 317, 293, 46, 319, 318, 48, 320, 322, 50, 323, - 266, 324, 343, 329, 334, 344, 348, 352, 299, 353, - 23, 354, 355, 356, 357, 368, 328, 371, 379, 370, - 384, 2, 372, 376, 377, 380, 385, 378, 128, 172, - 188, 233, 305, 219, 58, 147, 206, 199, 86, 214, - 130, 97, 125, 293, 56, 72, 84, 299, 80, 375, - 333, 338, 275, 286, 214, 174, 305, 244, 0, 0, - 168, 0, 188, 0, 192, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 128, 0, 147, 0, 0, 0, - 0, 0, 0, 359, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 147, -}; -static const YYINT yycheck[] = { 4, - 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, - 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, - 6, 7, 27, 23, 11, 48, 31, 48, 46, 16, - 35, 48, 44, 23, 39, 22, 46, 46, 43, 46, - 46, 45, 47, 46, 46, 44, 51, 47, 0, 1, - 2, 3, 4, 5, 6, 7, 50, 47, 46, 48, - 47, 46, 46, 46, 50, 0, 1, 2, 3, 4, - 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, - 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, - 1, 2, 3, 4, 5, 6, 7, 46, 50, 46, - 48, 47, 48, 108, 0, 1, 2, 3, 4, 5, - 6, 7, 48, 47, 48, 50, 1, 2, 3, 4, - 5, 6, 7, 50, 47, 48, 47, 48, 48, 277, - 8, 50, 47, 48, 48, 140, 14, 15, 5, 50, - 48, 8, 43, 10, 11, 12, 13, 14, 15, 47, - 48, 44, 43, 5, 50, 22, 8, 44, 10, 11, - 12, 13, 14, 15, 44, 50, 8, 9, 10, 47, - 22, 176, 14, 47, 48, 17, 18, 19, 20, 21, - 47, 8, 9, 10, 47, 48, 28, 14, 47, 48, - 17, 18, 19, 20, 21, 47, 8, 47, 48, 44, - 10, 28, 14, 15, 14, 47, 36, 37, 11, 51, - 52, 43, 43, 16, 24, 25, 26, 27, 44, 22, - 47, 29, 30, 31, 51, 52, 10, 44, 44, 377, - 14, 44, 43, 256, 239, 47, 45, 47, 256, 256, - 24, 25, 26, 27, 47, 44, 256, 256, 44, 256, - 256, 44, 257, 256, 256, 260, 256, 44, 263, 44, - 48, 44, 256, 47, 44, 44, 256, 256, 256, 256, - 256, 256, 256, 256, 38, 39, 40, 41, 42, 32, - 33, 34, 35, 44, 44, 44, 44, 44, 44, 44, - 27, 296, 31, 43, 48, 47, 47, 302, 47, 45, - 44, 48, 44, 308, 256, 45, 47, 256, 256, 256, - 256, 44, 48, 47, 45, 45, 44, 44, 44, 44, - 256, 256, 256, 47, 45, 45, 44, 35, 47, 256, - 47, 44, 48, 256, 48, 256, 256, 256, 44, 48, - 44, 256, 256, 44, 47, 256, 44, 44, 256, 44, - 206, 47, 44, 47, 47, 44, 44, 44, 256, 44, - 256, 44, 44, 44, 44, 44, 296, 44, 44, 47, - 44, 256, 47, 45, 45, 48, 44, 47, 256, 44, - 44, 44, 256, 44, 44, 44, 44, 44, 44, 256, - 44, 44, 44, 256, 23, 39, 51, 256, 47, 364, - 302, 308, 225, 239, 256, 140, 256, 182, -1, -1, - 133, -1, 155, -1, 256, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 256, -1, 256, -1, -1, -1, - -1, -1, -1, 256, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 256, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 #endif -#define YYMAXTOKEN 256 -#define YYUNDFTOKEN 393 -#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) + + +extern YYSTYPE yylval; + + +int yyparse (void); + + +#endif /* !YY_YY_WMLPARSE_H_INCLUDED */ +/* Symbol kind. */ +enum yysymbol_kind_t +{ + YYSYMBOL_YYEMPTY = -2, + YYSYMBOL_YYEOF = 0, /* "end of file" */ + YYSYMBOL_YYerror = 1, /* error */ + YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ + YYSYMBOL_CLASS = 3, /* CLASS */ + YYSYMBOL_RESOURCE = 4, /* RESOURCE */ + YYSYMBOL_DATATYPE = 5, /* DATATYPE */ + YYSYMBOL_CONTROLLIST = 6, /* CONTROLLIST */ + YYSYMBOL_ENUMERATIONSET = 7, /* ENUMERATIONSET */ + YYSYMBOL_ENUMERATIONVALUE = 8, /* ENUMERATIONVALUE */ + YYSYMBOL_CHARACTERSET = 9, /* CHARACTERSET */ + YYSYMBOL_CHILD = 10, /* CHILD */ + YYSYMBOL_DOCNAME = 11, /* DOCNAME */ + YYSYMBOL_CONVFUNC = 12, /* CONVFUNC */ + YYSYMBOL_ALIAS = 13, /* ALIAS */ + YYSYMBOL_TYPE = 14, /* TYPE */ + YYSYMBOL_RESOURCELITERAL = 15, /* RESOURCELITERAL */ + YYSYMBOL_RELATED = 16, /* RELATED */ + YYSYMBOL_INTERNALLITERAL = 17, /* INTERNALLITERAL */ + YYSYMBOL_XRMRESOURCE = 18, /* XRMRESOURCE */ + YYSYMBOL_EXCLUDE = 19, /* EXCLUDE */ + YYSYMBOL_RESOURCES = 20, /* RESOURCES */ + YYSYMBOL_SUPERCLASS = 21, /* SUPERCLASS */ + YYSYMBOL_CONTROLS = 22, /* CONTROLS */ + YYSYMBOL_WIDGETCLASS = 23, /* WIDGETCLASS */ + YYSYMBOL_DIALOGCLASS = 24, /* DIALOGCLASS */ + YYSYMBOL_DEFAULT = 25, /* DEFAULT */ + YYSYMBOL_ENUMLITERAL = 26, /* ENUMLITERAL */ + YYSYMBOL_XMSTRINGCHARSETNAME = 27, /* XMSTRINGCHARSETNAME */ + YYSYMBOL_DIRECTION = 28, /* DIRECTION */ + YYSYMBOL_PARSEDIRECTION = 29, /* PARSEDIRECTION */ + YYSYMBOL_CHARACTERSIZE = 30, /* CHARACTERSIZE */ + YYSYMBOL_CTRLMAPSRESOURCE = 31, /* CTRLMAPSRESOURCE */ + YYSYMBOL_CHILDREN = 32, /* CHILDREN */ + YYSYMBOL_PARENTCLASS = 33, /* PARENTCLASS */ + YYSYMBOL_METACLASS = 34, /* METACLASS */ + YYSYMBOL_WIDGET = 35, /* WIDGET */ + YYSYMBOL_GADGET = 36, /* GADGET */ + YYSYMBOL_ARGUMENT = 37, /* ARGUMENT */ + YYSYMBOL_REASON = 38, /* REASON */ + YYSYMBOL_CONSTRAINT = 39, /* CONSTRAINT */ + YYSYMBOL_SUBRESOURCE = 40, /* SUBRESOURCE */ + YYSYMBOL_ATTRTRUE = 41, /* ATTRTRUE */ + YYSYMBOL_ATTRFALSE = 42, /* ATTRFALSE */ + YYSYMBOL_LEFTTORIGHT = 43, /* LEFTTORIGHT */ + YYSYMBOL_RIGHTTOLEFT = 44, /* RIGHTTOLEFT */ + YYSYMBOL_ONEBYTE = 45, /* ONEBYTE */ + YYSYMBOL_TWOBYTE = 46, /* TWOBYTE */ + YYSYMBOL_MIXED1_2BYTE = 47, /* MIXED1_2BYTE */ + YYSYMBOL_COLON = 48, /* COLON */ + YYSYMBOL_SEMICOLON = 49, /* SEMICOLON */ + YYSYMBOL_EQUALS = 50, /* EQUALS */ + YYSYMBOL_LBRACE = 51, /* LBRACE */ + YYSYMBOL_RBRACE = 52, /* RBRACE */ + YYSYMBOL_STRING = 53, /* STRING */ + YYSYMBOL_ERRORTOKEN = 54, /* ERRORTOKEN */ + YYSYMBOL_YYACCEPT = 55, /* $accept */ + YYSYMBOL_statement_block_list = 56, /* statement_block_list */ + YYSYMBOL_statement_block = 57, /* statement_block */ + YYSYMBOL_58_1 = 58, /* $@1 */ + YYSYMBOL_class_statement_block = 59, /* class_statement_block */ + YYSYMBOL_class_statement_list = 60, /* class_statement_list */ + YYSYMBOL_61_2 = 61, /* $@2 */ + YYSYMBOL_resource_statement_block = 62, /* resource_statement_block */ + YYSYMBOL_resource_statement_list = 63, /* resource_statement_list */ + YYSYMBOL_64_3 = 64, /* $@3 */ + YYSYMBOL_child_statement_block = 65, /* child_statement_block */ + YYSYMBOL_child_statement_list = 66, /* child_statement_list */ + YYSYMBOL_67_4 = 67, /* $@4 */ + YYSYMBOL_datatype_statement_block = 68, /* datatype_statement_block */ + YYSYMBOL_datatype_statement_list = 69, /* datatype_statement_list */ + YYSYMBOL_70_5 = 70, /* $@5 */ + YYSYMBOL_ctrlist_statement_block = 71, /* ctrlist_statement_block */ + YYSYMBOL_ctrlist_statement_list = 72, /* ctrlist_statement_list */ + YYSYMBOL_73_6 = 73, /* $@6 */ + YYSYMBOL_enumset_statement_block = 74, /* enumset_statement_block */ + YYSYMBOL_enumset_statement_list = 75, /* enumset_statement_list */ + YYSYMBOL_76_7 = 76, /* $@7 */ + YYSYMBOL_enumval_statement_block = 77, /* enumval_statement_block */ + YYSYMBOL_enumval_statement_list = 78, /* enumval_statement_list */ + YYSYMBOL_79_8 = 79, /* $@8 */ + YYSYMBOL_charset_statement_block = 80, /* charset_statement_block */ + YYSYMBOL_charset_statement_list = 81, /* charset_statement_list */ + YYSYMBOL_82_9 = 82, /* $@9 */ + YYSYMBOL_class_statement = 83, /* class_statement */ + YYSYMBOL_84_10 = 84, /* $@10 */ + YYSYMBOL_class_type = 85, /* class_type */ + YYSYMBOL_class_definition = 86, /* class_definition */ + YYSYMBOL_87_11 = 87, /* $@11 */ + YYSYMBOL_class_attribute_list = 88, /* class_attribute_list */ + YYSYMBOL_class_attribute = 89, /* class_attribute */ + YYSYMBOL_90_12 = 90, /* $@12 */ + YYSYMBOL_91_13 = 91, /* $@13 */ + YYSYMBOL_92_14 = 92, /* $@14 */ + YYSYMBOL_class_attribute_name = 93, /* class_attribute_name */ + YYSYMBOL_boolean_class_attribute_name = 94, /* boolean_class_attribute_name */ + YYSYMBOL_boolean_attribute_value = 95, /* boolean_attribute_value */ + YYSYMBOL_class_resources = 96, /* class_resources */ + YYSYMBOL_class_resources_block = 97, /* class_resources_block */ + YYSYMBOL_98_15 = 98, /* $@15 */ + YYSYMBOL_class_resource_list = 99, /* class_resource_list */ + YYSYMBOL_class_resource_element = 100, /* class_resource_element */ + YYSYMBOL_101_16 = 101, /* $@16 */ + YYSYMBOL_102_17 = 102, /* $@17 */ + YYSYMBOL_class_resource_attributes = 103, /* class_resource_attributes */ + YYSYMBOL_104_18 = 104, /* $@18 */ + YYSYMBOL_class_resource_attribute_list = 105, /* class_resource_attribute_list */ + YYSYMBOL_class_resource_attribute_element = 106, /* class_resource_attribute_element */ + YYSYMBOL_107_19 = 107, /* $@19 */ + YYSYMBOL_108_20 = 108, /* $@20 */ + YYSYMBOL_109_21 = 109, /* $@21 */ + YYSYMBOL_class_resource_attribute_name = 110, /* class_resource_attribute_name */ + YYSYMBOL_boolean_class_resource_attribute_name = 111, /* boolean_class_resource_attribute_name */ + YYSYMBOL_class_controls = 112, /* class_controls */ + YYSYMBOL_class_controls_block = 113, /* class_controls_block */ + YYSYMBOL_114_22 = 114, /* $@22 */ + YYSYMBOL_class_controls_list = 115, /* class_controls_list */ + YYSYMBOL_class_controls_element = 116, /* class_controls_element */ + YYSYMBOL_117_23 = 117, /* $@23 */ + YYSYMBOL_118_24 = 118, /* $@24 */ + YYSYMBOL_class_controls_attributes = 119, /* class_controls_attributes */ + YYSYMBOL_120_25 = 120, /* $@25 */ + YYSYMBOL_class_children = 121, /* class_children */ + YYSYMBOL_class_children_block = 122, /* class_children_block */ + YYSYMBOL_123_26 = 123, /* $@26 */ + YYSYMBOL_class_children_list = 124, /* class_children_list */ + YYSYMBOL_class_children_element = 125, /* class_children_element */ + YYSYMBOL_126_27 = 126, /* $@27 */ + YYSYMBOL_127_28 = 127, /* $@28 */ + YYSYMBOL_resource_statement = 128, /* resource_statement */ + YYSYMBOL_129_29 = 129, /* $@29 */ + YYSYMBOL_resource_type = 130, /* resource_type */ + YYSYMBOL_resource_definition = 131, /* resource_definition */ + YYSYMBOL_132_30 = 132, /* $@30 */ + YYSYMBOL_resource_attribute_list = 133, /* resource_attribute_list */ + YYSYMBOL_resource_attribute = 134, /* resource_attribute */ + YYSYMBOL_135_31 = 135, /* $@31 */ + YYSYMBOL_136_32 = 136, /* $@32 */ + YYSYMBOL_137_33 = 137, /* $@33 */ + YYSYMBOL_resource_attribute_name = 138, /* resource_attribute_name */ + YYSYMBOL_boolean_resource_resource_attribute_name = 139, /* boolean_resource_resource_attribute_name */ + YYSYMBOL_child_statement = 140, /* child_statement */ + YYSYMBOL_datatype_statement = 141, /* datatype_statement */ + YYSYMBOL_142_34 = 142, /* $@34 */ + YYSYMBOL_datatype_definition = 143, /* datatype_definition */ + YYSYMBOL_144_35 = 144, /* $@35 */ + YYSYMBOL_datatype_attribute_list = 145, /* datatype_attribute_list */ + YYSYMBOL_datatype_attribute = 146, /* datatype_attribute */ + YYSYMBOL_147_36 = 147, /* $@36 */ + YYSYMBOL_148_37 = 148, /* $@37 */ + YYSYMBOL_datatype_attribute_name = 149, /* datatype_attribute_name */ + YYSYMBOL_ctrlist_statement = 150, /* ctrlist_statement */ + YYSYMBOL_151_38 = 151, /* $@38 */ + YYSYMBOL_ctrlist_definition = 152, /* ctrlist_definition */ + YYSYMBOL_153_39 = 153, /* $@39 */ + YYSYMBOL_ctrlist_controls_list = 154, /* ctrlist_controls_list */ + YYSYMBOL_ctrlist_control = 155, /* ctrlist_control */ + YYSYMBOL_156_40 = 156, /* $@40 */ + YYSYMBOL_157_41 = 157, /* $@41 */ + YYSYMBOL_ctrlist_controls_attributes = 158, /* ctrlist_controls_attributes */ + YYSYMBOL_159_42 = 159, /* $@42 */ + YYSYMBOL_enumset_statement = 160, /* enumset_statement */ + YYSYMBOL_161_43 = 161, /* $@43 */ + YYSYMBOL_enumset_data_type = 162, /* enumset_data_type */ + YYSYMBOL_enumset_definition = 163, /* enumset_definition */ + YYSYMBOL_164_44 = 164, /* $@44 */ + YYSYMBOL_enumset_value_list = 165, /* enumset_value_list */ + YYSYMBOL_enumset_value = 166, /* enumset_value */ + YYSYMBOL_167_45 = 167, /* $@45 */ + YYSYMBOL_168_46 = 168, /* $@46 */ + YYSYMBOL_enumval_statement = 169, /* enumval_statement */ + YYSYMBOL_170_47 = 170, /* $@47 */ + YYSYMBOL_enumvalue_definition = 171, /* enumvalue_definition */ + YYSYMBOL_172_48 = 172, /* $@48 */ + YYSYMBOL_enumvalue_attributes_list = 173, /* enumvalue_attributes_list */ + YYSYMBOL_enumvalue_attribute = 174, /* enumvalue_attribute */ + YYSYMBOL_175_49 = 175, /* $@49 */ + YYSYMBOL_176_50 = 176, /* $@50 */ + YYSYMBOL_enumvalue_attribute_name = 177, /* enumvalue_attribute_name */ + YYSYMBOL_charset_statement = 178, /* charset_statement */ + YYSYMBOL_179_51 = 179, /* $@51 */ + YYSYMBOL_charset_definition = 180, /* charset_definition */ + YYSYMBOL_181_52 = 181, /* $@52 */ + YYSYMBOL_charset_attribute_list = 182, /* charset_attribute_list */ + YYSYMBOL_charset_attribute = 183, /* charset_attribute */ + YYSYMBOL_184_53 = 184, /* $@53 */ + YYSYMBOL_185_54 = 185, /* $@54 */ + YYSYMBOL_186_55 = 186, /* $@55 */ + YYSYMBOL_charset_attribute_name = 187, /* charset_attribute_name */ + YYSYMBOL_predefined_charset_attribute_name = 188, /* predefined_charset_attribute_name */ + YYSYMBOL_predefined_charset_attribute_value = 189, /* predefined_charset_attribute_value */ + YYSYMBOL_name = 190 /* name */ +}; +typedef enum yysymbol_kind_t yysymbol_kind_t; + + + + +#ifdef short +# undef short +#endif + +/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure + and (if available) are included + so that the code can choose integer types of a good width. */ + +#ifndef __PTRDIFF_MAX__ +# include /* INFRINGES ON USER NAME SPACE */ +# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_STDINT_H +# endif +#endif + +/* Narrow types that promote to a signed type and that can represent a + signed or unsigned integer of at least N bits. In tables they can + save space and decrease cache pressure. Promoting to a signed type + helps avoid bugs in integer arithmetic. */ + +#ifdef __INT_LEAST8_MAX__ +typedef __INT_LEAST8_TYPE__ yytype_int8; +#elif defined YY_STDINT_H +typedef int_least8_t yytype_int8; +#else +typedef signed char yytype_int8; +#endif + +#ifdef __INT_LEAST16_MAX__ +typedef __INT_LEAST16_TYPE__ yytype_int16; +#elif defined YY_STDINT_H +typedef int_least16_t yytype_int16; +#else +typedef short yytype_int16; +#endif + +/* Work around bug in HP-UX 11.23, which defines these macros + incorrectly for preprocessor constants. This workaround can likely + be removed in 2023, as HPE has promised support for HP-UX 11.23 + (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of + . */ +#ifdef __hpux +# undef UINT_LEAST8_MAX +# undef UINT_LEAST16_MAX +# define UINT_LEAST8_MAX 255 +# define UINT_LEAST16_MAX 65535 +#endif + +#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST8_TYPE__ yytype_uint8; +#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST8_MAX <= INT_MAX) +typedef uint_least8_t yytype_uint8; +#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX +typedef unsigned char yytype_uint8; +#else +typedef short yytype_uint8; +#endif + +#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST16_TYPE__ yytype_uint16; +#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST16_MAX <= INT_MAX) +typedef uint_least16_t yytype_uint16; +#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX +typedef unsigned short yytype_uint16; +#else +typedef int yytype_uint16; +#endif + +#ifndef YYPTRDIFF_T +# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ +# define YYPTRDIFF_T __PTRDIFF_TYPE__ +# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ +# elif defined PTRDIFF_MAX +# ifndef ptrdiff_t +# include /* INFRINGES ON USER NAME SPACE */ +# endif +# define YYPTRDIFF_T ptrdiff_t +# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX +# else +# define YYPTRDIFF_T long +# define YYPTRDIFF_MAXIMUM LONG_MAX +# endif +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned +# endif +#endif + +#define YYSIZE_MAXIMUM \ + YY_CAST (YYPTRDIFF_T, \ + (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ + ? YYPTRDIFF_MAXIMUM \ + : YY_CAST (YYSIZE_T, -1))) + +#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) + + +/* Stored state numbers (used for stacks). */ +typedef yytype_int16 yy_state_t; + +/* State numbers in computations. */ +typedef int yy_state_fast_t; + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# endif +# endif +# ifndef YY_ +# define YY_(Msgid) Msgid +# endif +#endif + + +#ifndef YY_ATTRIBUTE_PURE +# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define YY_ATTRIBUTE_PURE +# endif +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +# else +# define YY_ATTRIBUTE_UNUSED +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YY_USE(E) ((void) (E)) +#else +# define YY_USE(E) /* empty */ +#endif + +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__ +# if __GNUC__ * 100 + __GNUC_MINOR__ < 407 +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") +# else +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# endif +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_INITIAL_VALUE(Value) Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + +#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ +# define YY_IGNORE_USELESS_CAST_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") +# define YY_IGNORE_USELESS_CAST_END \ + _Pragma ("GCC diagnostic pop") +#endif +#ifndef YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_END +#endif + + +#define YY_ASSERT(E) ((void) (0 && (E))) + +#if !defined yyoverflow + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# include /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* !defined yyoverflow */ + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yy_state_t yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +# define YYCOPY_NEEDED 1 + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYPTRDIFF_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / YYSIZEOF (*yyptr); \ + } \ + while (0) + +#endif + +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYPTRDIFF_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 2 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 339 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 55 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 136 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 258 +/* YYNSTATES -- Number of states. */ +#define YYNSTATES 387 + +/* YYMAXUTOK -- Last valid token kind. */ +#define YYMAXUTOK 257 + + +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ +#define YYTRANSLATE(YYX) \ + (0 <= (YYX) && (YYX) <= YYMAXUTOK \ + ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \ + : YYSYMBOL_YYUNDEF) + +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex. */ +static const yytype_int8 yytranslate[] = +{ + 0, 3, 4, 5, 6, 7, 8, 9, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 10, 32, 33, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2 +}; + #if YYDEBUG -static const char *const yyname[] = { - -"end-of-file","CLASS","RESOURCE","DATATYPE","CONTROLLIST","ENUMERATIONSET", -"ENUMERATIONVALUE","CHARACTERSET","DOCNAME","CONVFUNC","ALIAS","TYPE", -"RESOURCELITERAL","RELATED","INTERNALLITERAL","XRMRESOURCE","EXCLUDE", -"RESOURCES","SUPERCLASS","CONTROLS","WIDGETCLASS","DIALOGCLASS","DEFAULT", -"ENUMLITERAL","XMSTRINGCHARSETNAME","DIRECTION","PARSEDIRECTION", -"CHARACTERSIZE","CTRLMAPSRESOURCE","METACLASS","WIDGET","GADGET","ARGUMENT", -"REASON","CONSTRAINT","SUBRESOURCE","ATTRTRUE","ATTRFALSE","LEFTTORIGHT", -"RIGHTTOLEFT","ONEBYTE","TWOBYTE","MIXED1_2BYTE","COLON","SEMICOLON","EQUALS", -"LBRACE","RBRACE","STRING","ERRORTOKEN","CHILD","CHILDREN","PARENTCLASS",0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"illegal-symbol", -}; -static const char *const yyrule[] = { -"$accept : statement_block_list", -"statement_block_list :", -"statement_block_list : statement_block_list statement_block", -"statement_block : class_statement_block", -"statement_block : resource_statement_block", -"statement_block : child_statement_block", -"statement_block : datatype_statement_block", -"statement_block : ctrlist_statement_block", -"statement_block : enumset_statement_block", -"statement_block : enumval_statement_block", -"statement_block : charset_statement_block", -"$$1 :", -"statement_block : error $$1 SEMICOLON", -"class_statement_block : CLASS class_statement_list", -"class_statement_list : class_statement SEMICOLON", -"class_statement_list : class_statement_list class_statement SEMICOLON", -"$$2 :", -"class_statement_list : error $$2 SEMICOLON", -"resource_statement_block : RESOURCE resource_statement_list", -"resource_statement_list : resource_statement SEMICOLON", -"resource_statement_list : resource_statement_list resource_statement SEMICOLON", -"$$3 :", -"resource_statement_list : error $$3 SEMICOLON", -"child_statement_block : CHILD child_statement_list", -"child_statement_list : child_statement SEMICOLON", -"child_statement_list : child_statement_list child_statement SEMICOLON", -"$$4 :", -"child_statement_list : error $$4 SEMICOLON", -"datatype_statement_block : DATATYPE datatype_statement_list", -"datatype_statement_list : datatype_statement SEMICOLON", -"datatype_statement_list : datatype_statement_list datatype_statement SEMICOLON", -"$$5 :", -"datatype_statement_list : error $$5 SEMICOLON", -"ctrlist_statement_block : CONTROLLIST ctrlist_statement_list", -"ctrlist_statement_list : ctrlist_statement SEMICOLON", -"ctrlist_statement_list : ctrlist_statement_list ctrlist_statement SEMICOLON", -"$$6 :", -"ctrlist_statement_list : error $$6 SEMICOLON", -"enumset_statement_block : ENUMERATIONSET enumset_statement_list", -"enumset_statement_list : enumset_statement SEMICOLON", -"enumset_statement_list : enumset_statement_list enumset_statement SEMICOLON", -"$$7 :", -"enumset_statement_list : error $$7 SEMICOLON", -"enumval_statement_block : ENUMERATIONVALUE enumval_statement_list", -"enumval_statement_list : enumval_statement SEMICOLON", -"enumval_statement_list : enumval_statement_list enumval_statement SEMICOLON", -"$$8 :", -"enumval_statement_list : error $$8 SEMICOLON", -"charset_statement_block : CHARACTERSET charset_statement_list", -"charset_statement_list : charset_statement SEMICOLON", -"charset_statement_list : charset_statement_list charset_statement SEMICOLON", -"$$9 :", -"charset_statement_list : error $$9 SEMICOLON", -"$$10 :", -"class_statement : name COLON class_type $$10 class_definition", -"class_type : METACLASS", -"class_type : WIDGET", -"class_type : GADGET", -"class_definition :", -"class_definition : LBRACE RBRACE", -"class_definition : LBRACE class_attribute_list RBRACE", -"$$11 :", -"class_definition : error $$11 RBRACE", -"class_attribute_list : class_attribute", -"class_attribute_list : class_attribute_list class_attribute", -"$$12 :", -"class_attribute : class_attribute_name EQUALS STRING $$12 SEMICOLON", -"$$13 :", -"class_attribute : boolean_class_attribute_name EQUALS boolean_attribute_value $$13 SEMICOLON", -"class_attribute : class_resources SEMICOLON", -"class_attribute : class_controls SEMICOLON", -"class_attribute : class_children SEMICOLON", -"$$14 :", -"class_attribute : error $$14 SEMICOLON", -"class_attribute_name : SUPERCLASS", -"class_attribute_name : PARENTCLASS", -"class_attribute_name : INTERNALLITERAL", -"class_attribute_name : DOCNAME", -"class_attribute_name : CONVFUNC", -"class_attribute_name : WIDGETCLASS", -"class_attribute_name : CTRLMAPSRESOURCE", -"class_attribute_name : ALIAS", -"boolean_class_attribute_name : DIALOGCLASS", -"boolean_attribute_value : ATTRTRUE", -"boolean_attribute_value : ATTRFALSE", -"class_resources : RESOURCES class_resources_block", -"class_resources_block :", -"class_resources_block : LBRACE RBRACE", -"class_resources_block : LBRACE class_resource_list RBRACE", -"$$15 :", -"class_resources_block : error $$15 RBRACE", -"class_resource_list : class_resource_element", -"class_resource_list : class_resource_list class_resource_element", -"$$16 :", -"class_resource_element : name $$16 class_resource_attributes SEMICOLON", -"$$17 :", -"class_resource_element : error $$17 SEMICOLON", -"class_resource_attributes :", -"class_resource_attributes : LBRACE RBRACE", -"class_resource_attributes : LBRACE class_resource_attribute_list RBRACE", -"$$18 :", -"class_resource_attributes : error $$18 RBRACE", -"class_resource_attribute_list : class_resource_attribute_element", -"class_resource_attribute_list : class_resource_attribute_list class_resource_attribute_element", -"$$19 :", -"class_resource_attribute_element : class_resource_attribute_name EQUALS STRING $$19 SEMICOLON", -"$$20 :", -"class_resource_attribute_element : boolean_class_resource_attribute_name EQUALS boolean_attribute_value $$20 SEMICOLON", -"$$21 :", -"class_resource_attribute_element : error $$21 SEMICOLON", -"class_resource_attribute_name : TYPE", -"class_resource_attribute_name : DEFAULT", -"boolean_class_resource_attribute_name : EXCLUDE", -"class_controls : CONTROLS class_controls_block", -"class_controls_block :", -"class_controls_block : LBRACE RBRACE", -"class_controls_block : LBRACE class_controls_list RBRACE", -"$$22 :", -"class_controls_block : error $$22 RBRACE", -"class_controls_list : class_controls_element", -"class_controls_list : class_controls_list class_controls_element", -"$$23 :", -"class_controls_element : name $$23 class_controls_attributes SEMICOLON", -"$$24 :", -"class_controls_element : error $$24 SEMICOLON", -"class_controls_attributes :", -"class_controls_attributes : LBRACE RBRACE", -"$$25 :", -"class_controls_attributes : error $$25 RBRACE", -"class_children : CHILDREN class_children_block", -"class_children_block :", -"class_children_block : LBRACE RBRACE", -"class_children_block : LBRACE class_children_list RBRACE", -"$$26 :", -"class_children_block : error $$26 RBRACE", -"class_children_list : class_children_element", -"class_children_list : class_children_list class_children_element", -"$$27 :", -"class_children_element : name $$27 SEMICOLON", -"$$28 :", -"class_children_element : error $$28 SEMICOLON", -"$$29 :", -"resource_statement : name COLON resource_type $$29 resource_definition", -"resource_type : ARGUMENT", -"resource_type : REASON", -"resource_type : CONSTRAINT", -"resource_type : SUBRESOURCE", -"resource_definition :", -"resource_definition : LBRACE RBRACE", -"resource_definition : LBRACE resource_attribute_list RBRACE", -"$$30 :", -"resource_definition : error $$30 RBRACE", -"resource_attribute_list : resource_attribute", -"resource_attribute_list : resource_attribute_list resource_attribute", -"$$31 :", -"resource_attribute : resource_attribute_name EQUALS STRING $$31 SEMICOLON", -"$$32 :", -"resource_attribute : boolean_resource_resource_attribute_name EQUALS boolean_attribute_value $$32 SEMICOLON", -"$$33 :", -"resource_attribute : error $$33 SEMICOLON", -"resource_attribute_name : TYPE", -"resource_attribute_name : RESOURCELITERAL", -"resource_attribute_name : ENUMERATIONSET", -"resource_attribute_name : INTERNALLITERAL", -"resource_attribute_name : RELATED", -"resource_attribute_name : DOCNAME", -"resource_attribute_name : DEFAULT", -"resource_attribute_name : ALIAS", -"boolean_resource_resource_attribute_name : XRMRESOURCE", -"child_statement : name COLON STRING", -"$$34 :", -"datatype_statement : name $$34 datatype_definition", -"datatype_definition :", -"datatype_definition : LBRACE RBRACE", -"datatype_definition : LBRACE datatype_attribute_list RBRACE", -"$$35 :", -"datatype_definition : error $$35 RBRACE", -"datatype_attribute_list : datatype_attribute", -"datatype_attribute_list : datatype_attribute_list datatype_attribute", -"$$36 :", -"datatype_attribute : datatype_attribute_name EQUALS STRING $$36 SEMICOLON", -"$$37 :", -"datatype_attribute : error $$37 SEMICOLON", -"datatype_attribute_name : INTERNALLITERAL", -"datatype_attribute_name : DOCNAME", -"datatype_attribute_name : XRMRESOURCE", -"$$38 :", -"ctrlist_statement : name $$38 ctrlist_definition", -"ctrlist_definition :", -"ctrlist_definition : LBRACE RBRACE", -"ctrlist_definition : LBRACE ctrlist_controls_list RBRACE", -"$$39 :", -"ctrlist_definition : error $$39 RBRACE", -"ctrlist_controls_list : ctrlist_control", -"ctrlist_controls_list : ctrlist_controls_list ctrlist_control", -"$$40 :", -"ctrlist_control : name $$40 ctrlist_controls_attributes SEMICOLON", -"$$41 :", -"ctrlist_control : error $$41 SEMICOLON", -"ctrlist_controls_attributes :", -"ctrlist_controls_attributes : LBRACE RBRACE", -"$$42 :", -"ctrlist_controls_attributes : error $$42 RBRACE", -"$$43 :", -"enumset_statement : name COLON enumset_data_type $$43 enumset_definition", -"enumset_data_type : STRING", -"enumset_definition :", -"enumset_definition : LBRACE RBRACE", -"enumset_definition : LBRACE enumset_value_list RBRACE", -"$$44 :", -"enumset_definition : error $$44 RBRACE", -"enumset_value_list : enumset_value", -"enumset_value_list : enumset_value_list enumset_value", -"$$45 :", -"enumset_value : name $$45 SEMICOLON", -"$$46 :", -"enumset_value : error $$46 SEMICOLON", -"$$47 :", -"enumval_statement : name COLON $$47 enumvalue_definition", -"enumvalue_definition :", -"enumvalue_definition : LBRACE RBRACE", -"enumvalue_definition : LBRACE enumvalue_attributes_list RBRACE", -"$$48 :", -"enumvalue_definition : error $$48 RBRACE", -"enumvalue_attributes_list : enumvalue_attribute", -"enumvalue_attributes_list : enumvalue_attributes_list enumvalue_attribute", -"$$49 :", -"enumvalue_attribute : enumvalue_attribute_name EQUALS STRING $$49 SEMICOLON", -"$$50 :", -"enumvalue_attribute : error $$50 SEMICOLON", -"enumvalue_attribute_name : ENUMLITERAL", -"$$51 :", -"charset_statement : name $$51 charset_definition", -"charset_definition :", -"charset_definition : LBRACE RBRACE", -"charset_definition : LBRACE charset_attribute_list RBRACE", -"$$52 :", -"charset_definition : error $$52 RBRACE", -"charset_attribute_list : charset_attribute", -"charset_attribute_list : charset_attribute_list charset_attribute", -"$$53 :", -"charset_attribute : charset_attribute_name EQUALS STRING $$53 SEMICOLON", -"$$54 :", -"charset_attribute : predefined_charset_attribute_name EQUALS predefined_charset_attribute_value $$54 SEMICOLON", -"$$55 :", -"charset_attribute : error $$55 SEMICOLON", -"charset_attribute_name : INTERNALLITERAL", -"charset_attribute_name : ALIAS", -"charset_attribute_name : XMSTRINGCHARSETNAME", -"predefined_charset_attribute_name : DIRECTION", -"predefined_charset_attribute_name : PARSEDIRECTION", -"predefined_charset_attribute_name : CHARACTERSIZE", -"predefined_charset_attribute_value : LEFTTORIGHT", -"predefined_charset_attribute_value : RIGHTTOLEFT", -"predefined_charset_attribute_value : ONEBYTE", -"predefined_charset_attribute_value : TWOBYTE", -"predefined_charset_attribute_value : MIXED1_2BYTE", -"name : STRING", - +/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_int16 yyrline[] = +{ + 0, 169, 169, 170, 174, 175, 176, 177, 178, 179, + 180, 181, 182, 182, 191, 196, 197, 198, 198, 202, + 207, 208, 209, 209, 213, 218, 219, 220, 220, 224, + 229, 230, 231, 231, 235, 240, 241, 242, 242, 246, + 251, 252, 253, 253, 257, 262, 263, 264, 264, 268, + 273, 274, 275, 275, 287, 284, 292, 293, 294, 298, + 299, 300, 301, 301, 305, 306, 320, 317, 325, 322, + 327, 328, 329, 330, 330, 334, 335, 336, 337, 338, + 339, 340, 341, 345, 349, 350, 354, 358, 359, 360, + 361, 361, 365, 366, 371, 370, 374, 374, 378, 379, + 380, 381, 381, 385, 386, 393, 390, 398, 395, 400, + 400, 404, 405, 409, 413, 417, 418, 419, 420, 420, + 424, 425, 430, 429, 433, 433, 437, 438, 439, 439, + 443, 447, 448, 449, 450, 450, 454, 455, 460, 459, + 462, 462, 474, 471, 479, 480, 481, 482, 486, 487, + 488, 489, 489, 493, 494, 501, 498, 506, 503, 508, + 508, 512, 513, 514, 515, 516, 517, 518, 519, 523, + 531, 541, 540, 546, 547, 548, 549, 549, 553, 554, + 561, 558, 563, 563, 567, 568, 569, 579, 578, 584, + 585, 586, 587, 587, 591, 592, 597, 596, 600, 600, + 604, 605, 606, 606, 618, 615, 624, 628, 629, 630, + 631, 631, 635, 636, 641, 640, 643, 643, 654, 652, + 659, 660, 661, 662, 662, 666, 667, 674, 671, 676, + 676, 680, 690, 689, 695, 696, 697, 698, 698, 702, + 703, 710, 707, 715, 712, 717, 717, 721, 722, 723, + 727, 728, 729, 733, 734, 735, 736, 737, 745 }; #endif -int yydebug; -int yynerrs; +/** Accessing symbol of state STATE. */ +#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; +#if YYDEBUG || 0 +/* The user-facing name of the symbol whose (internal) number is + YYSYMBOL. No bounds checking. */ +static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; -/* define the initial stack-sizes */ -#ifdef YYSTACKSIZE -#undef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 10000 -#define YYMAXDEPTH 10000 -#endif +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "\"end of file\"", "error", "\"invalid token\"", "CLASS", "RESOURCE", + "DATATYPE", "CONTROLLIST", "ENUMERATIONSET", "ENUMERATIONVALUE", + "CHARACTERSET", "CHILD", "DOCNAME", "CONVFUNC", "ALIAS", "TYPE", + "RESOURCELITERAL", "RELATED", "INTERNALLITERAL", "XRMRESOURCE", + "EXCLUDE", "RESOURCES", "SUPERCLASS", "CONTROLS", "WIDGETCLASS", + "DIALOGCLASS", "DEFAULT", "ENUMLITERAL", "XMSTRINGCHARSETNAME", + "DIRECTION", "PARSEDIRECTION", "CHARACTERSIZE", "CTRLMAPSRESOURCE", + "CHILDREN", "PARENTCLASS", "METACLASS", "WIDGET", "GADGET", "ARGUMENT", + "REASON", "CONSTRAINT", "SUBRESOURCE", "ATTRTRUE", "ATTRFALSE", + "LEFTTORIGHT", "RIGHTTOLEFT", "ONEBYTE", "TWOBYTE", "MIXED1_2BYTE", + "COLON", "SEMICOLON", "EQUALS", "LBRACE", "RBRACE", "STRING", + "ERRORTOKEN", "$accept", "statement_block_list", "statement_block", + "$@1", "class_statement_block", "class_statement_list", "$@2", + "resource_statement_block", "resource_statement_list", "$@3", + "child_statement_block", "child_statement_list", "$@4", + "datatype_statement_block", "datatype_statement_list", "$@5", + "ctrlist_statement_block", "ctrlist_statement_list", "$@6", + "enumset_statement_block", "enumset_statement_list", "$@7", + "enumval_statement_block", "enumval_statement_list", "$@8", + "charset_statement_block", "charset_statement_list", "$@9", + "class_statement", "$@10", "class_type", "class_definition", "$@11", + "class_attribute_list", "class_attribute", "$@12", "$@13", "$@14", + "class_attribute_name", "boolean_class_attribute_name", + "boolean_attribute_value", "class_resources", "class_resources_block", + "$@15", "class_resource_list", "class_resource_element", "$@16", "$@17", + "class_resource_attributes", "$@18", "class_resource_attribute_list", + "class_resource_attribute_element", "$@19", "$@20", "$@21", + "class_resource_attribute_name", "boolean_class_resource_attribute_name", + "class_controls", "class_controls_block", "$@22", "class_controls_list", + "class_controls_element", "$@23", "$@24", "class_controls_attributes", + "$@25", "class_children", "class_children_block", "$@26", + "class_children_list", "class_children_element", "$@27", "$@28", + "resource_statement", "$@29", "resource_type", "resource_definition", + "$@30", "resource_attribute_list", "resource_attribute", "$@31", "$@32", + "$@33", "resource_attribute_name", + "boolean_resource_resource_attribute_name", "child_statement", + "datatype_statement", "$@34", "datatype_definition", "$@35", + "datatype_attribute_list", "datatype_attribute", "$@36", "$@37", + "datatype_attribute_name", "ctrlist_statement", "$@38", + "ctrlist_definition", "$@39", "ctrlist_controls_list", "ctrlist_control", + "$@40", "$@41", "ctrlist_controls_attributes", "$@42", + "enumset_statement", "$@43", "enumset_data_type", "enumset_definition", + "$@44", "enumset_value_list", "enumset_value", "$@45", "$@46", + "enumval_statement", "$@47", "enumvalue_definition", "$@48", + "enumvalue_attributes_list", "enumvalue_attribute", "$@49", "$@50", + "enumvalue_attribute_name", "charset_statement", "$@51", + "charset_definition", "$@52", "charset_attribute_list", + "charset_attribute", "$@53", "$@54", "$@55", "charset_attribute_name", + "predefined_charset_attribute_name", + "predefined_charset_attribute_value", "name", YY_NULLPTR +}; + +static const char * +yysymbol_name (yysymbol_kind_t yysymbol) +{ + return yytname[yysymbol]; +} #endif -#define YYINITSTACKSIZE 200 +#define YYPACT_NINF (-272) -typedef struct { - unsigned stacksize; - YYINT *s_base; - YYINT *s_mark; - YYINT *s_last; - YYSTYPE *l_base; - YYSTYPE *l_mark; -} YYSTACKDATA; -/* variables for the parser stack */ -static YYSTACKDATA yystack; +#define yypact_value_is_default(Yyn) \ + ((Yyn) == YYPACT_NINF) + +#define YYTABLE_NINF (-235) + +#define yytable_value_is_error(Yyn) \ + 0 + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int16 yypact[] = +{ + -272, 264, -272, -272, 27, 28, 29, 31, 32, 33, + 35, 36, -272, -272, -272, -272, -272, -272, -272, -272, + -272, -40, -272, -272, -42, -36, -33, -272, -42, -32, + -29, -272, -42, -28, -272, -272, -42, -24, -272, -272, + -42, -11, -2, -272, -42, 2, 4, -272, -42, 6, + -272, -272, -42, 38, 5, -272, 54, 66, -272, 150, + 67, 69, -272, 238, 70, 74, -272, 43, 77, 83, + -272, 44, 93, 97, -272, 99, 101, 105, -272, -272, + 107, 114, -272, 47, 117, 118, -272, 155, -272, -272, + -272, -272, -272, -272, -272, -272, -272, -272, -272, -272, + -272, -272, -272, -272, 39, -272, -272, -272, -272, 7, + -272, -272, -272, -272, -272, -272, -272, 48, -272, -272, + -272, 170, -272, -272, -272, -272, 124, 142, 153, -272, + -272, -272, -272, -272, 113, -272, 8, 157, -272, -272, + 9, -272, -272, 143, -272, 53, -272, 158, -272, -272, + -272, -272, -272, -272, -272, -272, 189, -272, 162, 164, + -272, 89, -272, -272, 144, -272, -272, 172, -272, -272, + 173, -272, 174, -272, -272, 152, -272, 11, -272, 175, + -272, -272, -272, 82, -272, 178, -272, 184, -272, -272, + 183, 204, 186, -272, -272, -272, -272, -272, 181, -272, + 188, -272, -272, -272, 194, -272, -272, 116, -272, 190, + 192, 195, 197, 208, 214, -272, -272, -272, -272, -272, + -272, -272, -272, -272, -272, -272, 163, -272, 205, 229, + -272, -272, -272, -272, 228, 211, 230, -272, -272, 13, + -272, -272, -272, 232, -272, -272, 231, -272, -272, -272, + -272, -272, -272, -272, -272, -272, 234, -272, 15, -272, + -272, 17, -272, -272, 19, -272, -272, -272, 233, 0, + -272, -272, -272, -272, 236, -272, -272, 235, 0, 240, + 241, -272, -272, -272, 243, -272, -272, 245, -272, -272, + 246, 247, -272, 248, -272, -272, 21, -272, -272, 249, + -272, -272, 23, -272, -272, 250, -272, -272, 25, -272, + -272, -272, -272, -272, -272, -272, -272, -272, -272, -272, + -272, -272, 255, -272, -272, -272, 256, -272, -272, 203, + -272, 257, -272, -272, 212, -272, 258, -272, -272, 259, + 260, 261, 262, 263, -272, -272, -272, 206, 265, -272, + -272, 266, 267, -272, -272, -272, -272, -272, -272, 268, + -272, -272, -272, -272, -272, 210, -272, 237, 269, -272, + 270, -272, -272, -272, 272, -272, -272, 271, 0, -272, + -272, -272, -272, 274, 276, -272, -272 +}; + +/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_int16 yydefact[] = +{ + 2, 0, 1, 12, 0, 0, 0, 0, 0, 0, + 0, 0, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 0, 17, 258, 14, 0, 0, 22, 19, 0, + 0, 32, 29, 0, 171, 37, 34, 0, 187, 42, + 39, 0, 0, 47, 44, 0, 0, 52, 49, 0, + 232, 27, 24, 0, 0, 13, 0, 0, 15, 0, + 0, 0, 20, 0, 0, 0, 30, 0, 0, 0, + 35, 0, 0, 0, 40, 0, 0, 0, 45, 218, + 0, 0, 50, 0, 0, 0, 25, 0, 18, 16, + 56, 57, 58, 54, 23, 21, 144, 145, 146, 147, + 142, 33, 31, 176, 0, 172, 38, 36, 192, 0, + 188, 43, 41, 206, 204, 48, 46, 0, 53, 51, + 237, 0, 233, 28, 26, 170, 0, 0, 0, 182, + 185, 184, 186, 174, 0, 178, 0, 0, 198, 190, + 0, 194, 196, 0, 223, 0, 219, 0, 245, 248, + 247, 249, 250, 251, 252, 235, 0, 239, 0, 0, + 62, 0, 55, 151, 0, 143, 177, 0, 175, 179, + 0, 193, 0, 191, 195, 0, 210, 0, 205, 0, + 229, 231, 221, 0, 225, 0, 238, 0, 236, 240, + 0, 0, 0, 73, 78, 79, 82, 77, 0, 75, + 0, 80, 83, 81, 0, 76, 60, 0, 64, 0, + 0, 0, 0, 0, 0, 159, 163, 166, 168, 161, + 162, 165, 164, 169, 167, 149, 0, 153, 0, 0, + 183, 180, 199, 202, 0, 0, 0, 216, 208, 0, + 212, 214, 224, 0, 222, 226, 0, 246, 241, 253, + 254, 255, 256, 257, 243, 63, 0, 90, 0, 86, + 118, 0, 114, 134, 0, 130, 61, 65, 0, 0, + 70, 71, 72, 152, 0, 150, 154, 0, 0, 0, + 0, 201, 197, 211, 0, 209, 213, 0, 230, 227, + 0, 0, 74, 0, 96, 88, 0, 92, 94, 0, + 124, 116, 0, 120, 122, 0, 140, 132, 0, 136, + 138, 66, 84, 85, 68, 160, 155, 157, 181, 203, + 217, 215, 0, 242, 244, 91, 0, 89, 93, 0, + 119, 0, 117, 121, 0, 135, 0, 133, 137, 0, + 0, 0, 0, 0, 228, 97, 101, 0, 0, 125, + 128, 0, 0, 141, 139, 67, 69, 156, 158, 0, + 109, 111, 113, 112, 99, 0, 103, 0, 0, 95, + 0, 127, 123, 102, 0, 100, 104, 0, 0, 129, + 110, 105, 107, 0, 0, 106, 108 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -272, -272, -272, -272, -272, -272, -272, -272, -272, -272, + -272, -272, -272, -272, -272, -272, -272, -272, -272, -272, + -272, -272, -272, -272, -272, -272, -272, -272, 275, -272, + -272, -272, -272, -272, 91, -272, -272, -272, -272, -272, + -271, -272, -272, -272, -272, -6, -272, -272, -272, -272, + -272, -52, -272, -272, -272, -272, -272, -272, -272, -272, + -272, 24, -272, -272, -272, -272, -272, -272, -272, -272, + 20, -272, -272, 287, -272, -272, -272, -272, -272, 103, + -272, -272, -272, -272, -272, 278, 285, -272, -272, -272, + -272, 193, -272, -272, -272, 295, -272, -272, -272, -272, + 196, -272, -272, -272, -272, 292, -272, -272, -272, -272, + -272, 94, -272, -272, 290, -272, -272, -272, -272, 154, + -272, -272, -272, 291, -272, -272, -272, -272, 179, -272, + -272, -272, -272, -272, -272, -5 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + 0, 1, 12, 21, 13, 24, 56, 14, 28, 60, + 15, 52, 84, 16, 32, 64, 17, 36, 68, 18, + 40, 72, 19, 44, 76, 20, 48, 80, 25, 126, + 93, 162, 192, 207, 208, 340, 341, 256, 209, 210, + 314, 211, 259, 293, 296, 297, 329, 326, 348, 359, + 365, 366, 383, 384, 374, 367, 368, 212, 262, 299, + 302, 303, 334, 331, 352, 370, 213, 265, 305, 308, + 309, 339, 336, 29, 127, 100, 165, 214, 226, 227, + 342, 343, 274, 228, 229, 53, 33, 67, 105, 128, + 134, 135, 279, 167, 136, 37, 71, 110, 137, 140, + 141, 175, 172, 235, 280, 41, 143, 114, 178, 236, + 239, 240, 287, 284, 45, 117, 146, 179, 183, 184, + 322, 243, 185, 49, 83, 122, 147, 156, 157, 290, + 291, 187, 158, 159, 254, 26 +}; + +/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_int16 yytable[] = +{ + 30, 34, 38, 42, 46, 50, 54, 317, 138, 55, + 138, 23, 237, 58, 237, 59, 294, 62, 300, 63, + 306, 66, 294, 30, 300, 70, 306, 34, 22, 27, + 31, 38, 35, 39, 43, 42, 47, 51, 74, 46, + 129, 312, 313, 50, 103, 108, 75, 54, 120, 144, + 130, 78, 79, 87, 180, 82, 131, 132, 170, 139, + 23, 173, 23, 238, 23, 285, 23, 295, 23, 301, + 23, 307, 23, 327, 23, 332, 23, 337, 23, 181, + 23, 23, 23, 180, 23, 23, 23, 86, 23, 23, + 193, 133, -173, -189, 104, 109, -234, -220, 121, 145, + 194, 195, 196, 88, 142, 182, 197, 382, 181, 198, + 199, 200, 201, 202, 129, 89, 94, 193, 95, 101, + 203, 204, 205, 102, 130, 160, 106, 194, 195, 196, + 131, 132, 107, 197, 244, 142, 198, 199, 200, 201, + 202, 206, 111, 163, 176, 215, 112, 203, 204, 205, + 115, 216, 113, 233, 116, 217, 118, 218, 219, 220, + 221, 222, 223, 119, 215, 168, 123, 124, 266, 224, + 216, 148, 241, -59, 217, 161, 218, 219, 220, 221, + 222, 223, 257, 149, 90, 91, 92, 150, 224, 260, + 148, -148, -207, 164, 177, 263, 225, 151, 152, 153, + 154, -200, 149, 234, 346, 166, 150, 360, 125, 171, + 186, 360, 190, 350, 191, 275, 151, 152, 153, 154, + 361, 230, 155, 232, 361, 362, 231, 242, 246, 362, + -87, 363, 258, 247, 241, 363, 248, -115, 255, 261, + 268, 188, 269, -131, 270, 264, 271, 249, 250, 251, + 252, 253, -98, 298, 347, 277, 304, 272, 364, 310, + 282, -126, 375, 351, 2, 3, 273, 4, 5, 6, + 7, 8, 9, 10, 11, 96, 97, 98, 99, 278, + 281, 288, 283, 292, 289, 315, 311, 377, 316, 318, + 328, 298, 320, 319, 321, 323, 324, 304, 267, 57, + 325, 330, 335, 310, 344, 345, 349, 353, 354, 355, + 356, 357, 358, 376, 369, 61, 372, 65, 371, 378, + 373, 380, 379, 385, 381, 386, 333, 169, 338, 276, + 85, 69, 73, 286, 77, 189, 174, 245, 0, 81 +}; + +static const yytype_int16 yycheck[] = +{ + 5, 6, 7, 8, 9, 10, 11, 278, 1, 49, + 1, 53, 1, 49, 1, 48, 1, 49, 1, 48, + 1, 49, 1, 28, 1, 49, 1, 32, 1, 1, + 1, 36, 1, 1, 1, 40, 1, 1, 49, 44, + 1, 41, 42, 48, 1, 1, 48, 52, 1, 1, + 11, 49, 48, 48, 1, 49, 17, 18, 50, 52, + 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, + 53, 52, 53, 52, 53, 52, 53, 52, 53, 26, + 53, 53, 53, 1, 53, 53, 53, 49, 53, 53, + 1, 52, 49, 49, 51, 51, 49, 49, 51, 51, + 11, 12, 13, 49, 109, 52, 17, 378, 26, 20, + 21, 22, 23, 24, 1, 49, 49, 1, 49, 49, + 31, 32, 33, 49, 11, 1, 49, 11, 12, 13, + 17, 18, 49, 17, 52, 140, 20, 21, 22, 23, + 24, 52, 49, 1, 1, 1, 49, 31, 32, 33, + 49, 7, 53, 1, 49, 11, 49, 13, 14, 15, + 16, 17, 18, 49, 1, 52, 49, 49, 52, 25, + 7, 1, 177, 49, 11, 51, 13, 14, 15, 16, + 17, 18, 1, 13, 34, 35, 36, 17, 25, 1, + 1, 49, 49, 51, 51, 1, 52, 27, 28, 29, + 30, 49, 13, 51, 1, 52, 17, 1, 53, 52, + 52, 1, 50, 1, 50, 52, 27, 28, 29, 30, + 14, 49, 52, 49, 14, 19, 53, 52, 50, 19, + 49, 25, 51, 49, 239, 25, 53, 49, 52, 51, + 50, 52, 50, 49, 49, 51, 49, 43, 44, 45, + 46, 47, 49, 258, 51, 50, 261, 49, 52, 264, + 49, 49, 52, 51, 0, 1, 52, 3, 4, 5, + 6, 7, 8, 9, 10, 37, 38, 39, 40, 50, + 52, 49, 52, 49, 53, 49, 53, 50, 53, 49, + 296, 296, 49, 52, 49, 49, 49, 302, 207, 24, + 52, 52, 52, 308, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 365, 49, 28, 49, 32, 52, 50, + 52, 49, 52, 49, 53, 49, 302, 134, 308, 226, + 52, 36, 40, 239, 44, 156, 140, 183, -1, 48 +}; + +/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of + state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 56, 0, 1, 3, 4, 5, 6, 7, 8, + 9, 10, 57, 59, 62, 65, 68, 71, 74, 77, + 80, 58, 1, 53, 60, 83, 190, 1, 63, 128, + 190, 1, 69, 141, 190, 1, 72, 150, 190, 1, + 75, 160, 190, 1, 78, 169, 190, 1, 81, 178, + 190, 1, 66, 140, 190, 49, 61, 83, 49, 48, + 64, 128, 49, 48, 70, 141, 49, 142, 73, 150, + 49, 151, 76, 160, 49, 48, 79, 169, 49, 48, + 82, 178, 49, 179, 67, 140, 49, 48, 49, 49, + 34, 35, 36, 85, 49, 49, 37, 38, 39, 40, + 130, 49, 49, 1, 51, 143, 49, 49, 1, 51, + 152, 49, 49, 53, 162, 49, 49, 170, 49, 49, + 1, 51, 180, 49, 49, 53, 84, 129, 144, 1, + 11, 17, 18, 52, 145, 146, 149, 153, 1, 52, + 154, 155, 190, 161, 1, 51, 171, 181, 1, 13, + 17, 27, 28, 29, 30, 52, 182, 183, 187, 188, + 1, 51, 86, 1, 51, 131, 52, 148, 52, 146, + 50, 52, 157, 52, 155, 156, 1, 51, 163, 172, + 1, 26, 52, 173, 174, 177, 52, 186, 52, 183, + 50, 50, 87, 1, 11, 12, 13, 17, 20, 21, + 22, 23, 24, 31, 32, 33, 52, 88, 89, 93, + 94, 96, 112, 121, 132, 1, 7, 11, 13, 14, + 15, 16, 17, 18, 25, 52, 133, 134, 138, 139, + 49, 53, 49, 1, 51, 158, 164, 1, 52, 165, + 166, 190, 52, 176, 52, 174, 50, 49, 53, 43, + 44, 45, 46, 47, 189, 52, 92, 1, 51, 97, + 1, 51, 113, 1, 51, 122, 52, 89, 50, 50, + 49, 49, 49, 52, 137, 52, 134, 50, 50, 147, + 159, 52, 49, 52, 168, 52, 166, 167, 49, 53, + 184, 185, 49, 98, 1, 52, 99, 100, 190, 114, + 1, 52, 115, 116, 190, 123, 1, 52, 124, 125, + 190, 53, 41, 42, 95, 49, 53, 95, 49, 52, + 49, 49, 175, 49, 49, 52, 102, 52, 100, 101, + 52, 118, 52, 116, 117, 52, 127, 52, 125, 126, + 90, 91, 135, 136, 49, 49, 1, 51, 103, 49, + 1, 51, 119, 49, 49, 49, 49, 49, 49, 104, + 1, 14, 19, 25, 52, 105, 106, 110, 111, 49, + 120, 52, 49, 52, 109, 52, 106, 50, 50, 52, + 49, 53, 95, 107, 108, 49, 49 +}; + +/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */ +static const yytype_uint8 yyr1[] = +{ + 0, 55, 56, 56, 57, 57, 57, 57, 57, 57, + 57, 57, 58, 57, 59, 60, 60, 61, 60, 62, + 63, 63, 64, 63, 65, 66, 66, 67, 66, 68, + 69, 69, 70, 69, 71, 72, 72, 73, 72, 74, + 75, 75, 76, 75, 77, 78, 78, 79, 78, 80, + 81, 81, 82, 81, 84, 83, 85, 85, 85, 86, + 86, 86, 87, 86, 88, 88, 90, 89, 91, 89, + 89, 89, 89, 92, 89, 93, 93, 93, 93, 93, + 93, 93, 93, 94, 95, 95, 96, 97, 97, 97, + 98, 97, 99, 99, 101, 100, 102, 100, 103, 103, + 103, 104, 103, 105, 105, 107, 106, 108, 106, 109, + 106, 110, 110, 111, 112, 113, 113, 113, 114, 113, + 115, 115, 117, 116, 118, 116, 119, 119, 120, 119, + 121, 122, 122, 122, 123, 122, 124, 124, 126, 125, + 127, 125, 129, 128, 130, 130, 130, 130, 131, 131, + 131, 132, 131, 133, 133, 135, 134, 136, 134, 137, + 134, 138, 138, 138, 138, 138, 138, 138, 138, 139, + 140, 142, 141, 143, 143, 143, 144, 143, 145, 145, + 147, 146, 148, 146, 149, 149, 149, 151, 150, 152, + 152, 152, 153, 152, 154, 154, 156, 155, 157, 155, + 158, 158, 159, 158, 161, 160, 162, 163, 163, 163, + 164, 163, 165, 165, 167, 166, 168, 166, 170, 169, + 171, 171, 171, 172, 171, 173, 173, 175, 174, 176, + 174, 177, 179, 178, 180, 180, 180, 181, 180, 182, + 182, 184, 183, 185, 183, 186, 183, 187, 187, 187, + 188, 188, 188, 189, 189, 189, 189, 189, 190 +}; + +/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ +static const yytype_int8 yyr2[] = +{ + 0, 2, 0, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 3, 2, 2, 3, 0, 3, 2, + 2, 3, 0, 3, 2, 2, 3, 0, 3, 2, + 2, 3, 0, 3, 2, 2, 3, 0, 3, 2, + 2, 3, 0, 3, 2, 2, 3, 0, 3, 2, + 2, 3, 0, 3, 0, 5, 1, 1, 1, 0, + 2, 3, 0, 3, 1, 2, 0, 5, 0, 5, + 2, 2, 2, 0, 3, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 2, 0, 2, 3, + 0, 3, 1, 2, 0, 4, 0, 3, 0, 2, + 3, 0, 3, 1, 2, 0, 5, 0, 5, 0, + 3, 1, 1, 1, 2, 0, 2, 3, 0, 3, + 1, 2, 0, 4, 0, 3, 0, 2, 0, 3, + 2, 0, 2, 3, 0, 3, 1, 2, 0, 3, + 0, 3, 0, 5, 1, 1, 1, 1, 0, 2, + 3, 0, 3, 1, 2, 0, 5, 0, 5, 0, + 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 3, 0, 3, 0, 2, 3, 0, 3, 1, 2, + 0, 5, 0, 3, 1, 1, 1, 0, 3, 0, + 2, 3, 0, 3, 1, 2, 0, 4, 0, 3, + 0, 2, 0, 3, 0, 5, 1, 0, 2, 3, + 0, 3, 1, 2, 0, 3, 0, 3, 0, 4, + 0, 2, 3, 0, 3, 1, 2, 0, 5, 0, + 3, 1, 0, 3, 0, 2, 3, 0, 3, 1, + 2, 0, 5, 0, 5, 0, 3, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1 +}; + + +enum { YYENOMEM = -2 }; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab +#define YYNOMEM goto yyexhaustedlab + + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) + +/* Backward compatibility with an undocumented macro. + Use YYerror or YYUNDEF. */ +#define YYERRCODE YYUNDEF + + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + + + + +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Kind, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + + +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/ + +static void +yy_symbol_value_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) +{ + FILE *yyoutput = yyo; + YY_USE (yyoutput); + if (!yyvaluep) + return; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YY_USE (yykind); + YY_IGNORE_MAYBE_UNINITIALIZED_END +} + + +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/ + +static void +yy_symbol_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) +{ + YYFPRINTF (yyo, "%s %s (", + yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); + + yy_symbol_value_print (yyo, yykind, yyvaluep); + YYFPRINTF (yyo, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +static void +yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +static void +yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, + int yyrule) +{ + int yylno = yyrline[yyrule]; + int yynrhs = yyr2[yyrule]; + int yyi; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), + &yyvsp[(yyi + 1) - (yynrhs)]); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) ((void) 0) +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + + + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +static void +yydestruct (const char *yymsg, + yysymbol_kind_t yykind, YYSTYPE *yyvaluep) +{ + YY_USE (yyvaluep); + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YY_USE (yykind); + YY_IGNORE_MAYBE_UNINITIALIZED_END +} + + +/* Lookahead token kind. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; +/* Number of syntax errors so far. */ +int yynerrs; + + + + +/*----------. +| yyparse. | +`----------*/ + +int +yyparse (void) +{ + yy_state_fast_t yystate = 0; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus = 0; + + /* Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* Their size. */ + YYPTRDIFF_T yystacksize = YYINITDEPTH; + + /* The state stack: array, bottom, top. */ + yy_state_t yyssa[YYINITDEPTH]; + yy_state_t *yyss = yyssa; + yy_state_t *yyssp = yyss; + + /* The semantic value stack: array, bottom, top. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp = yyvs; + + int yyn; + /* The return value of yyparse. */ + int yyresult; + /* Lookahead symbol kind. */ + yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yychar = YYEMPTY; /* Cause a token to be read. */ + + goto yysetstate; + + +/*------------------------------------------------------------. +| yynewstate -- push a new state, which is found in yystate. | +`------------------------------------------------------------*/ +yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + +/*--------------------------------------------------------------------. +| yysetstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YY_ASSERT (0 <= yystate && yystate < YYNSTATES); + YY_IGNORE_USELESS_CAST_BEGIN + *yyssp = YY_CAST (yy_state_t, yystate); + YY_IGNORE_USELESS_CAST_END + YY_STACK_PRINT (yyss, yyssp); + + if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + YYNOMEM; +#else + { + /* Get the current used size of the three stacks, in elements. */ + YYPTRDIFF_T yysize = yyssp - yyss + 1; + +# if defined yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + yy_state_t *yyss1 = yyss; + YYSTYPE *yyvs1 = yyvs; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * YYSIZEOF (*yyssp), + &yyvs1, yysize * YYSIZEOF (*yyvsp), + &yystacksize); + yyss = yyss1; + yyvs = yyvs1; + } +# else /* defined YYSTACK_RELOCATE */ + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + YYNOMEM; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yy_state_t *yyss1 = yyss; + union yyalloc *yyptr = + YY_CAST (union yyalloc *, + YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); + if (! yyptr) + YYNOMEM; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YY_IGNORE_USELESS_CAST_BEGIN + YYDPRINTF ((stderr, "Stack size increased to %ld\n", + YY_CAST (long, yystacksize))); + YY_IGNORE_USELESS_CAST_END + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ + + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yypact_value_is_default (yyn)) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token\n")); + yychar = yylex (); + } + + if (yychar <= YYEOF) + { + yychar = YYEOF; + yytoken = YYSYMBOL_YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else if (yychar == YYerror) + { + /* The scanner already issued an error message, process directly + to error recovery. But do not keep the error token as + lookahead, it is too special and may lead us to an endless + loop in error recovery. */ + yychar = YYUNDEF; + yytoken = YYSYMBOL_YYerror; + goto yyerrlab1; + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yytable_value_is_error (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + /* Discard the shifted token. */ + yychar = YYEMPTY; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + '$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 12: /* $@1: %empty */ +#line 182 "wmlparse.y" + { LexIssueError(0); } +#line 1744 "wmlparse.c" + break; + + case 17: /* $@2: %empty */ +#line 198 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 1750 "wmlparse.c" + break; + + case 22: /* $@3: %empty */ +#line 209 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 1756 "wmlparse.c" + break; + + case 27: /* $@4: %empty */ +#line 220 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 1762 "wmlparse.c" + break; + + case 32: /* $@5: %empty */ +#line 231 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 1768 "wmlparse.c" + break; + + case 37: /* $@6: %empty */ +#line 242 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 1774 "wmlparse.c" + break; + + case 42: /* $@7: %empty */ +#line 253 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 1780 "wmlparse.c" + break; + + case 47: /* $@8: %empty */ +#line 264 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 1786 "wmlparse.c" + break; + + case 52: /* $@9: %empty */ +#line 275 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 1792 "wmlparse.c" + break; + + case 54: /* $@10: %empty */ +#line 287 "wmlparse.y" + { wmlCreateClass (yynameval, yytknval1); } +#line 1798 "wmlparse.c" + break; + + case 56: /* class_type: METACLASS */ +#line 292 "wmlparse.y" + { yytknval1 = METACLASS; } +#line 1804 "wmlparse.c" + break; + + case 57: /* class_type: WIDGET */ +#line 293 "wmlparse.y" + { yytknval1 = WIDGET; } +#line 1810 "wmlparse.c" + break; + + case 58: /* class_type: GADGET */ +#line 294 "wmlparse.y" + { yytknval1 = GADGET; } +#line 1816 "wmlparse.c" + break; + + case 62: /* $@11: %empty */ +#line 301 "wmlparse.y" + { LexIssueError(RBRACE); } +#line 1822 "wmlparse.c" + break; + + case 66: /* $@12: %empty */ +#line 320 "wmlparse.y" + { wmlAddClassAttribute (yytknval1, yystringval); } +#line 1828 "wmlparse.c" + break; + + case 68: /* $@13: %empty */ +#line 325 "wmlparse.y" + { wmlAddClassAttribute (yytknval1, (char *) (long) yytknval2); } +#line 1834 "wmlparse.c" + break; + + case 73: /* $@14: %empty */ +#line 330 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 1840 "wmlparse.c" + break; + + case 75: /* class_attribute_name: SUPERCLASS */ +#line 334 "wmlparse.y" + { yytknval1 = SUPERCLASS; } +#line 1846 "wmlparse.c" + break; + + case 76: /* class_attribute_name: PARENTCLASS */ +#line 335 "wmlparse.y" + { yytknval1 = PARENTCLASS; } +#line 1852 "wmlparse.c" + break; + + case 77: /* class_attribute_name: INTERNALLITERAL */ +#line 336 "wmlparse.y" + { yytknval1 = INTERNALLITERAL; } +#line 1858 "wmlparse.c" + break; + + case 78: /* class_attribute_name: DOCNAME */ +#line 337 "wmlparse.y" + { yytknval1 = DOCNAME; } +#line 1864 "wmlparse.c" + break; + + case 79: /* class_attribute_name: CONVFUNC */ +#line 338 "wmlparse.y" + { yytknval1 = CONVFUNC; } +#line 1870 "wmlparse.c" + break; + + case 80: /* class_attribute_name: WIDGETCLASS */ +#line 339 "wmlparse.y" + { yytknval1 = WIDGETCLASS; } +#line 1876 "wmlparse.c" + break; + + case 81: /* class_attribute_name: CTRLMAPSRESOURCE */ +#line 340 "wmlparse.y" + { yytknval1 = CTRLMAPSRESOURCE; } +#line 1882 "wmlparse.c" + break; + + case 82: /* class_attribute_name: ALIAS */ +#line 341 "wmlparse.y" + { yytknval1 = ALIAS; } +#line 1888 "wmlparse.c" + break; + + case 83: /* boolean_class_attribute_name: DIALOGCLASS */ +#line 345 "wmlparse.y" + { yytknval1 = DIALOGCLASS; } +#line 1894 "wmlparse.c" + break; + + case 84: /* boolean_attribute_value: ATTRTRUE */ +#line 349 "wmlparse.y" + { yytknval2 = ATTRTRUE; } +#line 1900 "wmlparse.c" + break; + + case 85: /* boolean_attribute_value: ATTRFALSE */ +#line 350 "wmlparse.y" + { yytknval2 = ATTRFALSE; } +#line 1906 "wmlparse.c" + break; + + case 90: /* $@15: %empty */ +#line 361 "wmlparse.y" + { LexIssueError(RBRACE); } +#line 1912 "wmlparse.c" + break; + + case 94: /* $@16: %empty */ +#line 371 "wmlparse.y" + { wmlAddClassResource (yynameval); } +#line 1918 "wmlparse.c" + break; + + case 96: /* $@17: %empty */ +#line 374 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 1924 "wmlparse.c" + break; + + case 101: /* $@18: %empty */ +#line 381 "wmlparse.y" + { LexIssueError(RBRACE); } +#line 1930 "wmlparse.c" + break; + + case 105: /* $@19: %empty */ +#line 393 "wmlparse.y" + { wmlAddClassResourceAttribute (yytknval1, yystringval); } +#line 1936 "wmlparse.c" + break; + + case 107: /* $@20: %empty */ +#line 398 "wmlparse.y" + { wmlAddClassResourceAttribute (yytknval1, (char *) (long) yytknval2); } +#line 1942 "wmlparse.c" + break; + + case 109: /* $@21: %empty */ +#line 400 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 1948 "wmlparse.c" + break; + + case 111: /* class_resource_attribute_name: TYPE */ +#line 404 "wmlparse.y" + { yytknval1 = TYPE; } +#line 1954 "wmlparse.c" + break; + + case 112: /* class_resource_attribute_name: DEFAULT */ +#line 405 "wmlparse.y" + { yytknval1 = DEFAULT; } +#line 1960 "wmlparse.c" + break; + + case 113: /* boolean_class_resource_attribute_name: EXCLUDE */ +#line 409 "wmlparse.y" + { yytknval1 = EXCLUDE; } +#line 1966 "wmlparse.c" + break; + + case 118: /* $@22: %empty */ +#line 420 "wmlparse.y" + { LexIssueError(RBRACE); } +#line 1972 "wmlparse.c" + break; + + case 122: /* $@23: %empty */ +#line 430 "wmlparse.y" + { wmlAddClassControl (yynameval); } +#line 1978 "wmlparse.c" + break; + + case 124: /* $@24: %empty */ +#line 433 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 1984 "wmlparse.c" + break; + + case 128: /* $@25: %empty */ +#line 439 "wmlparse.y" + { LexIssueError(RBRACE); } +#line 1990 "wmlparse.c" + break; + + case 134: /* $@26: %empty */ +#line 450 "wmlparse.y" + { LexIssueError(RBRACE); } +#line 1996 "wmlparse.c" + break; + + case 138: /* $@27: %empty */ +#line 460 "wmlparse.y" + { wmlAddClassChild (yynameval); } +#line 2002 "wmlparse.c" + break; + + case 140: /* $@28: %empty */ +#line 462 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 2008 "wmlparse.c" + break; + + case 142: /* $@29: %empty */ +#line 474 "wmlparse.y" + { wmlCreateResource (yynameval, yytknval1); } +#line 2014 "wmlparse.c" + break; + + case 144: /* resource_type: ARGUMENT */ +#line 479 "wmlparse.y" + { yytknval1 = ARGUMENT; } +#line 2020 "wmlparse.c" + break; + + case 145: /* resource_type: REASON */ +#line 480 "wmlparse.y" + { yytknval1 = REASON; } +#line 2026 "wmlparse.c" + break; + + case 146: /* resource_type: CONSTRAINT */ +#line 481 "wmlparse.y" + { yytknval1 = CONSTRAINT; } +#line 2032 "wmlparse.c" + break; + + case 147: /* resource_type: SUBRESOURCE */ +#line 482 "wmlparse.y" + { yytknval1 = SUBRESOURCE; } +#line 2038 "wmlparse.c" + break; + + case 151: /* $@30: %empty */ +#line 489 "wmlparse.y" + { LexIssueError(RBRACE); } +#line 2044 "wmlparse.c" + break; + + case 155: /* $@31: %empty */ +#line 501 "wmlparse.y" + { wmlAddResourceAttribute (yytknval1, yystringval); } +#line 2050 "wmlparse.c" + break; + + case 157: /* $@32: %empty */ +#line 506 "wmlparse.y" + { wmlAddResourceAttribute (yytknval1, (char *) (long) yytknval2); } +#line 2056 "wmlparse.c" + break; + + case 159: /* $@33: %empty */ +#line 508 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 2062 "wmlparse.c" + break; + + case 161: /* resource_attribute_name: TYPE */ +#line 512 "wmlparse.y" + { yytknval1 = TYPE; } +#line 2068 "wmlparse.c" + break; + + case 162: /* resource_attribute_name: RESOURCELITERAL */ +#line 513 "wmlparse.y" + { yytknval1 = RESOURCELITERAL; } +#line 2074 "wmlparse.c" + break; + + case 163: /* resource_attribute_name: ENUMERATIONSET */ +#line 514 "wmlparse.y" + { yytknval1 = ENUMERATIONSET; } +#line 2080 "wmlparse.c" + break; + + case 164: /* resource_attribute_name: INTERNALLITERAL */ +#line 515 "wmlparse.y" + { yytknval1 = INTERNALLITERAL; } +#line 2086 "wmlparse.c" + break; + + case 165: /* resource_attribute_name: RELATED */ +#line 516 "wmlparse.y" + { yytknval1 = RELATED; } +#line 2092 "wmlparse.c" + break; + + case 166: /* resource_attribute_name: DOCNAME */ +#line 517 "wmlparse.y" + { yytknval1 = DOCNAME; } +#line 2098 "wmlparse.c" + break; + + case 167: /* resource_attribute_name: DEFAULT */ +#line 518 "wmlparse.y" + { yytknval1 = DEFAULT; } +#line 2104 "wmlparse.c" + break; + + case 168: /* resource_attribute_name: ALIAS */ +#line 519 "wmlparse.y" + { yytknval1 = ALIAS; } +#line 2110 "wmlparse.c" + break; + + case 169: /* boolean_resource_resource_attribute_name: XRMRESOURCE */ +#line 523 "wmlparse.y" + { yytknval1 = XRMRESOURCE; } +#line 2116 "wmlparse.c" + break; + + case 170: /* child_statement: name COLON STRING */ +#line 532 "wmlparse.y" + { wmlCreateChild(yynameval, yystringval); } +#line 2122 "wmlparse.c" + break; + + case 171: /* $@34: %empty */ +#line 541 "wmlparse.y" + { wmlCreateDatatype (yystringval); } +#line 2128 "wmlparse.c" + break; + + case 176: /* $@35: %empty */ +#line 549 "wmlparse.y" + { LexIssueError(RBRACE); } +#line 2134 "wmlparse.c" + break; + + case 180: /* $@36: %empty */ +#line 561 "wmlparse.y" + { wmlAddDatatypeAttribute (yytknval1, yystringval); } +#line 2140 "wmlparse.c" + break; + + case 182: /* $@37: %empty */ +#line 563 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 2146 "wmlparse.c" + break; + + case 184: /* datatype_attribute_name: INTERNALLITERAL */ +#line 567 "wmlparse.y" + { yytknval1 = INTERNALLITERAL; } +#line 2152 "wmlparse.c" + break; + + case 185: /* datatype_attribute_name: DOCNAME */ +#line 568 "wmlparse.y" + { yytknval1 = DOCNAME; } +#line 2158 "wmlparse.c" + break; + + case 186: /* datatype_attribute_name: XRMRESOURCE */ +#line 569 "wmlparse.y" + { yytknval1 = XRMRESOURCE; } +#line 2164 "wmlparse.c" + break; + + case 187: /* $@38: %empty */ +#line 579 "wmlparse.y" + { wmlCreateOrAppendCtrlList (yynameval); } +#line 2170 "wmlparse.c" + break; + + case 192: /* $@39: %empty */ +#line 587 "wmlparse.y" + { LexIssueError(RBRACE); } +#line 2176 "wmlparse.c" + break; + + case 196: /* $@40: %empty */ +#line 597 "wmlparse.y" + { wmlAddCtrlListControl (yynameval); } +#line 2182 "wmlparse.c" + break; + + case 198: /* $@41: %empty */ +#line 600 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 2188 "wmlparse.c" + break; + + case 202: /* $@42: %empty */ +#line 606 "wmlparse.y" + { LexIssueError(RBRACE); } +#line 2194 "wmlparse.c" + break; + + case 204: /* $@43: %empty */ +#line 618 "wmlparse.y" + { wmlCreateEnumSet (yynameval, yystringval); } +#line 2200 "wmlparse.c" + break; + + case 210: /* $@44: %empty */ +#line 631 "wmlparse.y" + { LexIssueError(RBRACE); } +#line 2206 "wmlparse.c" + break; + + case 214: /* $@45: %empty */ +#line 641 "wmlparse.y" + { wmlAddEnumSetValue (yynameval); } +#line 2212 "wmlparse.c" + break; + + case 216: /* $@46: %empty */ +#line 643 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 2218 "wmlparse.c" + break; + + case 218: /* $@47: %empty */ +#line 654 "wmlparse.y" + { wmlCreateEnumValue (yynameval); } +#line 2224 "wmlparse.c" + break; + + case 223: /* $@48: %empty */ +#line 662 "wmlparse.y" + { LexIssueError(RBRACE); } +#line 2230 "wmlparse.c" + break; + + case 227: /* $@49: %empty */ +#line 674 "wmlparse.y" + { wmlAddEnumValueAttribute (yytknval1, yystringval); } +#line 2236 "wmlparse.c" + break; + + case 229: /* $@50: %empty */ +#line 676 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 2242 "wmlparse.c" + break; + + case 231: /* enumvalue_attribute_name: ENUMLITERAL */ +#line 680 "wmlparse.y" + { yytknval1 = ENUMLITERAL; } +#line 2248 "wmlparse.c" + break; + + case 232: /* $@51: %empty */ +#line 690 "wmlparse.y" + { wmlCreateCharset (yystringval); } +#line 2254 "wmlparse.c" + break; + + case 237: /* $@52: %empty */ +#line 698 "wmlparse.y" + { LexIssueError(RBRACE); } +#line 2260 "wmlparse.c" + break; + + case 241: /* $@53: %empty */ +#line 710 "wmlparse.y" + { wmlAddCharsetAttribute (yytknval1, yystringval); } +#line 2266 "wmlparse.c" + break; + + case 243: /* $@54: %empty */ +#line 715 "wmlparse.y" + { wmlAddCharsetAttribute (yytknval1, (char *) (long) yytknval2); } +#line 2272 "wmlparse.c" + break; + + case 245: /* $@55: %empty */ +#line 717 "wmlparse.y" + { LexIssueError(SEMICOLON); } +#line 2278 "wmlparse.c" + break; + + case 247: /* charset_attribute_name: INTERNALLITERAL */ +#line 721 "wmlparse.y" + { yytknval1 = INTERNALLITERAL; } +#line 2284 "wmlparse.c" + break; + + case 248: /* charset_attribute_name: ALIAS */ +#line 722 "wmlparse.y" + { yytknval1 = ALIAS; } +#line 2290 "wmlparse.c" + break; + + case 249: /* charset_attribute_name: XMSTRINGCHARSETNAME */ +#line 723 "wmlparse.y" + { yytknval1 = XMSTRINGCHARSETNAME; } +#line 2296 "wmlparse.c" + break; + + case 250: /* predefined_charset_attribute_name: DIRECTION */ +#line 727 "wmlparse.y" + { yytknval1 = DIRECTION; } +#line 2302 "wmlparse.c" + break; + + case 251: /* predefined_charset_attribute_name: PARSEDIRECTION */ +#line 728 "wmlparse.y" + { yytknval1 = PARSEDIRECTION; } +#line 2308 "wmlparse.c" + break; + + case 252: /* predefined_charset_attribute_name: CHARACTERSIZE */ +#line 729 "wmlparse.y" + { yytknval1 = CHARACTERSIZE; } +#line 2314 "wmlparse.c" + break; + + case 253: /* predefined_charset_attribute_value: LEFTTORIGHT */ +#line 733 "wmlparse.y" + { yytknval2 = LEFTTORIGHT; } +#line 2320 "wmlparse.c" + break; + + case 254: /* predefined_charset_attribute_value: RIGHTTOLEFT */ +#line 734 "wmlparse.y" + { yytknval2 = RIGHTTOLEFT; } +#line 2326 "wmlparse.c" + break; + + case 255: /* predefined_charset_attribute_value: ONEBYTE */ #line 735 "wmlparse.y" + { yytknval2 = ONEBYTE; } +#line 2332 "wmlparse.c" + break; + + case 256: /* predefined_charset_attribute_value: TWOBYTE */ +#line 736 "wmlparse.y" + { yytknval2 = TWOBYTE; } +#line 2338 "wmlparse.c" + break; + + case 257: /* predefined_charset_attribute_value: MIXED1_2BYTE */ +#line 737 "wmlparse.y" + { yytknval2 = MIXED1_2BYTE; } +#line 2344 "wmlparse.c" + break; + + case 258: /* name: STRING */ +#line 746 "wmlparse.y" + { strcpy (yynameval, (XmConst char *)yystringval); } +#line 2350 "wmlparse.c" + break; + + +#line 2354 "wmlparse.c" + + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + + *++yyvsp = yyval; + + /* Now 'shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + { + const int yylhs = yyr1[yyn] - YYNTOKENS; + const int yyi = yypgoto[yylhs] + *yyssp; + yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp + ? yytable[yyi] + : yydefgoto[yylhs]); + } + + goto yynewstate; + + +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ +yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; + yyerror (YY_("syntax error")); + } + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; + ++yynerrs; + + /* Do not reclaim the symbols of the rule whose action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + /* Pop stack until we find a state that shifts the error token. */ + for (;;) + { + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYSYMBOL_YYerror; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + YY_ACCESSING_SYMBOL (yystate), yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturnlab; + + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturnlab; + + +/*-----------------------------------------------------------. +| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. | +`-----------------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + goto yyreturnlab; + + +/*----------------------------------------------------------. +| yyreturnlab -- parsing is finished, clean up and return. | +`----------------------------------------------------------*/ +yyreturnlab: + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } + /* Do not reclaim the symbols of the rule whose action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + YY_ACCESSING_SYMBOL (+*yyssp), yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + + return yyresult; +} + +#line 749 "wmlparse.y" + /* * Dummmy error routine, since we output our own. @@ -784,673 +2558,3 @@ char *s; #include "wmllex.c" -#line 788 "wmlparse.c" - -#if YYDEBUG -#include /* needed for printf */ -#endif - -#include /* needed for malloc, etc */ -#include /* needed for memset */ - -/* allocate initial stack or double stack size, up to YYMAXDEPTH */ -static int yygrowstack(YYSTACKDATA *data) -{ - int i; - unsigned newsize; - YYINT *newss; - YYSTYPE *newvs; - - if ((newsize = data->stacksize) == 0) - newsize = YYINITSTACKSIZE; - else if (newsize >= YYMAXDEPTH) - return YYENOMEM; - else if ((newsize *= 2) > YYMAXDEPTH) - newsize = YYMAXDEPTH; - - i = (int) (data->s_mark - data->s_base); - newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); - if (newss == 0) - return YYENOMEM; - - data->s_base = newss; - data->s_mark = newss + i; - - newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); - if (newvs == 0) - return YYENOMEM; - - data->l_base = newvs; - data->l_mark = newvs + i; - - data->stacksize = newsize; - data->s_last = data->s_base + newsize - 1; - return 0; -} - -#if YYPURE || defined(YY_NO_LEAKS) -static void yyfreestack(YYSTACKDATA *data) -{ - free(data->s_base); - free(data->l_base); - memset(data, 0, sizeof(*data)); -} -#else -#define yyfreestack(data) /* nothing */ -#endif - -#define YYABORT goto yyabort -#define YYREJECT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab - -int -YYPARSE_DECL() -{ - int yym, yyn, yystate; -#if YYDEBUG - const char *yys; - - if ((yys = getenv("YYDEBUG")) != 0) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } -#endif - - yynerrs = 0; - yyerrflag = 0; - yychar = YYEMPTY; - yystate = 0; - -#if YYPURE - memset(&yystack, 0, sizeof(yystack)); -#endif - - if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; - yystack.s_mark = yystack.s_base; - yystack.l_mark = yystack.l_base; - yystate = 0; - *yystack.s_mark = 0; - -yyloop: - if ((yyn = yydefred[yystate]) != 0) goto yyreduce; - if (yychar < 0) - { - if ((yychar = YYLEX) < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - yys = yyname[YYTRANSLATE(yychar)]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - } - if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, shifting to state %d\n", - YYPREFIX, yystate, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - { - goto yyoverflow; - } - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - yychar = YYEMPTY; - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag) goto yyinrecovery; - - YYERROR_CALL("syntax error"); - - goto yyerrlab; - -yyerrlab: - ++yynerrs; - -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - { - goto yyoverflow; - } - yystate = yytable[yyn]; - *++yystack.s_mark = yytable[yyn]; - *++yystack.l_mark = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystack.s_mark); -#endif - if (yystack.s_mark <= yystack.s_base) goto yyabort; - --yystack.s_mark; - --yystack.l_mark; - } - } - } - else - { - if (yychar == YYEOF) goto yyabort; -#if YYDEBUG - if (yydebug) - { - yys = yyname[YYTRANSLATE(yychar)]; - printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yychar, yys); - } -#endif - yychar = YYEMPTY; - goto yyloop; - } - -yyreduce: -#if YYDEBUG - if (yydebug) - printf("%sdebug: state %d, reducing by rule %d (%s)\n", - YYPREFIX, yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - if (yym) - yyval = yystack.l_mark[1-yym]; - else - memset(&yyval, 0, sizeof yyval); - switch (yyn) - { -case 11: -#line 174 "wmlparse.y" - { LexIssueError(0); } -break; -case 16: -#line 190 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 21: -#line 201 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 26: -#line 212 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 31: -#line 223 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 36: -#line 234 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 41: -#line 245 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 46: -#line 256 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 51: -#line 267 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 53: -#line 279 "wmlparse.y" - { wmlCreateClass (yynameval, yytknval1); } -break; -case 55: -#line 284 "wmlparse.y" - { yytknval1 = METACLASS; } -break; -case 56: -#line 285 "wmlparse.y" - { yytknval1 = WIDGET; } -break; -case 57: -#line 286 "wmlparse.y" - { yytknval1 = GADGET; } -break; -case 61: -#line 293 "wmlparse.y" - { LexIssueError(RBRACE); } -break; -case 65: -#line 305 "wmlparse.y" - { wmlAddClassAttribute (yytknval1, yystringval); } -break; -case 67: -#line 310 "wmlparse.y" - { wmlAddClassAttribute (yytknval1, yytknval2); } -break; -case 72: -#line 315 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 74: -#line 319 "wmlparse.y" - { yytknval1 = SUPERCLASS; } -break; -case 75: -#line 320 "wmlparse.y" - { yytknval1 = PARENTCLASS; } -break; -case 76: -#line 321 "wmlparse.y" - { yytknval1 = INTERNALLITERAL; } -break; -case 77: -#line 322 "wmlparse.y" - { yytknval1 = DOCNAME; } -break; -case 78: -#line 323 "wmlparse.y" - { yytknval1 = CONVFUNC; } -break; -case 79: -#line 324 "wmlparse.y" - { yytknval1 = WIDGETCLASS; } -break; -case 80: -#line 325 "wmlparse.y" - { yytknval1 = CTRLMAPSRESOURCE; } -break; -case 81: -#line 326 "wmlparse.y" - { yytknval1 = ALIAS; } -break; -case 82: -#line 330 "wmlparse.y" - { yytknval1 = DIALOGCLASS; } -break; -case 83: -#line 334 "wmlparse.y" - { yytknval2 = ATTRTRUE; } -break; -case 84: -#line 335 "wmlparse.y" - { yytknval2 = ATTRFALSE; } -break; -case 89: -#line 346 "wmlparse.y" - { LexIssueError(RBRACE); } -break; -case 93: -#line 356 "wmlparse.y" - { wmlAddClassResource (yynameval); } -break; -case 95: -#line 359 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 100: -#line 366 "wmlparse.y" - { LexIssueError(RBRACE); } -break; -case 104: -#line 378 "wmlparse.y" - { wmlAddClassResourceAttribute (yytknval1, yystringval); } -break; -case 106: -#line 383 "wmlparse.y" - { wmlAddClassResourceAttribute (yytknval1, yytknval2); } -break; -case 108: -#line 385 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 110: -#line 389 "wmlparse.y" - { yytknval1 = TYPE; } -break; -case 111: -#line 390 "wmlparse.y" - { yytknval1 = DEFAULT; } -break; -case 112: -#line 394 "wmlparse.y" - { yytknval1 = EXCLUDE; } -break; -case 117: -#line 405 "wmlparse.y" - { LexIssueError(RBRACE); } -break; -case 121: -#line 415 "wmlparse.y" - { wmlAddClassControl (yynameval); } -break; -case 123: -#line 418 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 127: -#line 424 "wmlparse.y" - { LexIssueError(RBRACE); } -break; -case 133: -#line 435 "wmlparse.y" - { LexIssueError(RBRACE); } -break; -case 137: -#line 445 "wmlparse.y" - { wmlAddClassChild (yynameval); } -break; -case 139: -#line 447 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 141: -#line 459 "wmlparse.y" - { wmlCreateResource (yynameval, yytknval1); } -break; -case 143: -#line 464 "wmlparse.y" - { yytknval1 = ARGUMENT; } -break; -case 144: -#line 465 "wmlparse.y" - { yytknval1 = REASON; } -break; -case 145: -#line 466 "wmlparse.y" - { yytknval1 = CONSTRAINT; } -break; -case 146: -#line 467 "wmlparse.y" - { yytknval1 = SUBRESOURCE; } -break; -case 150: -#line 474 "wmlparse.y" - { LexIssueError(RBRACE); } -break; -case 154: -#line 486 "wmlparse.y" - { wmlAddResourceAttribute (yytknval1, yystringval); } -break; -case 156: -#line 491 "wmlparse.y" - { wmlAddResourceAttribute (yytknval1, yytknval2); } -break; -case 158: -#line 493 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 160: -#line 497 "wmlparse.y" - { yytknval1 = TYPE; } -break; -case 161: -#line 498 "wmlparse.y" - { yytknval1 = RESOURCELITERAL; } -break; -case 162: -#line 499 "wmlparse.y" - { yytknval1 = ENUMERATIONSET; } -break; -case 163: -#line 500 "wmlparse.y" - { yytknval1 = INTERNALLITERAL; } -break; -case 164: -#line 501 "wmlparse.y" - { yytknval1 = RELATED; } -break; -case 165: -#line 502 "wmlparse.y" - { yytknval1 = DOCNAME; } -break; -case 166: -#line 503 "wmlparse.y" - { yytknval1 = DEFAULT; } -break; -case 167: -#line 504 "wmlparse.y" - { yytknval1 = ALIAS; } -break; -case 168: -#line 508 "wmlparse.y" - { yytknval1 = XRMRESOURCE; } -break; -case 169: -#line 517 "wmlparse.y" - { wmlCreateChild(yynameval, yystringval); } -break; -case 170: -#line 526 "wmlparse.y" - { wmlCreateDatatype (yystringval); } -break; -case 175: -#line 534 "wmlparse.y" - { LexIssueError(RBRACE); } -break; -case 179: -#line 546 "wmlparse.y" - { wmlAddDatatypeAttribute (yytknval1, yystringval); } -break; -case 181: -#line 548 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 183: -#line 552 "wmlparse.y" - { yytknval1 = INTERNALLITERAL; } -break; -case 184: -#line 553 "wmlparse.y" - { yytknval1 = DOCNAME; } -break; -case 185: -#line 554 "wmlparse.y" - { yytknval1 = XRMRESOURCE; } -break; -case 186: -#line 564 "wmlparse.y" - { wmlCreateOrAppendCtrlList (yynameval); } -break; -case 191: -#line 572 "wmlparse.y" - { LexIssueError(RBRACE); } -break; -case 195: -#line 582 "wmlparse.y" - { wmlAddCtrlListControl (yynameval); } -break; -case 197: -#line 585 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 201: -#line 591 "wmlparse.y" - { LexIssueError(RBRACE); } -break; -case 203: -#line 603 "wmlparse.y" - { wmlCreateEnumSet (yynameval, yystringval); } -break; -case 209: -#line 616 "wmlparse.y" - { LexIssueError(RBRACE); } -break; -case 213: -#line 626 "wmlparse.y" - { wmlAddEnumSetValue (yynameval); } -break; -case 215: -#line 628 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 217: -#line 639 "wmlparse.y" - { wmlCreateEnumValue (yynameval); } -break; -case 222: -#line 647 "wmlparse.y" - { LexIssueError(RBRACE); } -break; -case 226: -#line 659 "wmlparse.y" - { wmlAddEnumValueAttribute (yytknval1, yystringval); } -break; -case 228: -#line 661 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 230: -#line 665 "wmlparse.y" - { yytknval1 = ENUMLITERAL; } -break; -case 231: -#line 675 "wmlparse.y" - { wmlCreateCharset (yystringval); } -break; -case 236: -#line 683 "wmlparse.y" - { LexIssueError(RBRACE); } -break; -case 240: -#line 695 "wmlparse.y" - { wmlAddCharsetAttribute (yytknval1, yystringval); } -break; -case 242: -#line 700 "wmlparse.y" - { wmlAddCharsetAttribute (yytknval1, yytknval2); } -break; -case 244: -#line 702 "wmlparse.y" - { LexIssueError(SEMICOLON); } -break; -case 246: -#line 706 "wmlparse.y" - { yytknval1 = INTERNALLITERAL; } -break; -case 247: -#line 707 "wmlparse.y" - { yytknval1 = ALIAS; } -break; -case 248: -#line 708 "wmlparse.y" - { yytknval1 = XMSTRINGCHARSETNAME; } -break; -case 249: -#line 712 "wmlparse.y" - { yytknval1 = DIRECTION; } -break; -case 250: -#line 713 "wmlparse.y" - { yytknval1 = PARSEDIRECTION; } -break; -case 251: -#line 714 "wmlparse.y" - { yytknval1 = CHARACTERSIZE; } -break; -case 252: -#line 718 "wmlparse.y" - { yytknval2 = LEFTTORIGHT; } -break; -case 253: -#line 719 "wmlparse.y" - { yytknval2 = RIGHTTOLEFT; } -break; -case 254: -#line 720 "wmlparse.y" - { yytknval2 = ONEBYTE; } -break; -case 255: -#line 721 "wmlparse.y" - { yytknval2 = TWOBYTE; } -break; -case 256: -#line 722 "wmlparse.y" - { yytknval2 = MIXED1_2BYTE; } -break; -case 257: -#line 731 "wmlparse.y" - { strcpy (yynameval, (XmConst char *)yystringval); } -break; -#line 1398 "wmlparse.c" - } - yystack.s_mark -= yym; - yystate = *yystack.s_mark; - yystack.l_mark -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state 0 to\ - state %d\n", YYPREFIX, YYFINAL); -#endif - yystate = YYFINAL; - *++yystack.s_mark = YYFINAL; - *++yystack.l_mark = yyval; - if (yychar < 0) - { - if ((yychar = YYLEX) < 0) yychar = YYEOF; -#if YYDEBUG - if (yydebug) - { - yys = yyname[YYTRANSLATE(yychar)]; - printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yychar, yys); - } -#endif - } - if (yychar == YYEOF) goto yyaccept; - goto yyloop; - } - if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystack.s_mark, yystate); -#endif - if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) - { - goto yyoverflow; - } - *++yystack.s_mark = (YYINT) yystate; - *++yystack.l_mark = yyval; - goto yyloop; - -yyoverflow: - YYERROR_CALL("yacc stack overflow"); - -yyabort: - yyfreestack(&yystack); - return (1); - -yyaccept: - yyfreestack(&yystack); - return (0); -} diff --git a/ext/src/mcde/motif/tools/wml/wmlparse.h b/ext/src/mcde/motif/tools/wml/wmlparse.h index 1e35236cb3..327f66d173 100644 --- a/ext/src/mcde/motif/tools/wml/wmlparse.h +++ b/ext/src/mcde/motif/tools/wml/wmlparse.h @@ -1,3 +1,119 @@ +/* A Bison parser, made by GNU Bison 3.8.2. */ + +/* Bison interface for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, + Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ + +#ifndef YY_YY_WMLPARSE_H_INCLUDED +# define YY_YY_WMLPARSE_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token kinds. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + YYEMPTY = -2, + YYEOF = 0, /* "end of file" */ + YYerror = 256, /* error */ + YYUNDEF = 257, /* "invalid token" */ + CLASS = 1, /* CLASS */ + RESOURCE = 2, /* RESOURCE */ + DATATYPE = 3, /* DATATYPE */ + CONTROLLIST = 4, /* CONTROLLIST */ + ENUMERATIONSET = 5, /* ENUMERATIONSET */ + ENUMERATIONVALUE = 6, /* ENUMERATIONVALUE */ + CHARACTERSET = 7, /* CHARACTERSET */ + CHILD = 50, /* CHILD */ + DOCNAME = 8, /* DOCNAME */ + CONVFUNC = 9, /* CONVFUNC */ + ALIAS = 10, /* ALIAS */ + TYPE = 11, /* TYPE */ + RESOURCELITERAL = 12, /* RESOURCELITERAL */ + RELATED = 13, /* RELATED */ + INTERNALLITERAL = 14, /* INTERNALLITERAL */ + XRMRESOURCE = 15, /* XRMRESOURCE */ + EXCLUDE = 16, /* EXCLUDE */ + RESOURCES = 17, /* RESOURCES */ + SUPERCLASS = 18, /* SUPERCLASS */ + CONTROLS = 19, /* CONTROLS */ + WIDGETCLASS = 20, /* WIDGETCLASS */ + DIALOGCLASS = 21, /* DIALOGCLASS */ + DEFAULT = 22, /* DEFAULT */ + ENUMLITERAL = 23, /* ENUMLITERAL */ + XMSTRINGCHARSETNAME = 24, /* XMSTRINGCHARSETNAME */ + DIRECTION = 25, /* DIRECTION */ + PARSEDIRECTION = 26, /* PARSEDIRECTION */ + CHARACTERSIZE = 27, /* CHARACTERSIZE */ + CTRLMAPSRESOURCE = 28, /* CTRLMAPSRESOURCE */ + CHILDREN = 51, /* CHILDREN */ + PARENTCLASS = 52, /* PARENTCLASS */ + METACLASS = 29, /* METACLASS */ + WIDGET = 30, /* WIDGET */ + GADGET = 31, /* GADGET */ + ARGUMENT = 32, /* ARGUMENT */ + REASON = 33, /* REASON */ + CONSTRAINT = 34, /* CONSTRAINT */ + SUBRESOURCE = 35, /* SUBRESOURCE */ + ATTRTRUE = 36, /* ATTRTRUE */ + ATTRFALSE = 37, /* ATTRFALSE */ + LEFTTORIGHT = 38, /* LEFTTORIGHT */ + RIGHTTOLEFT = 39, /* RIGHTTOLEFT */ + ONEBYTE = 40, /* ONEBYTE */ + TWOBYTE = 41, /* TWOBYTE */ + MIXED1_2BYTE = 42, /* MIXED1_2BYTE */ + COLON = 43, /* COLON */ + SEMICOLON = 44, /* SEMICOLON */ + EQUALS = 45, /* EQUALS */ + LBRACE = 46, /* LBRACE */ + RBRACE = 47, /* RBRACE */ + STRING = 48, /* STRING */ + ERRORTOKEN = 49 /* ERRORTOKEN */ + }; + typedef enum yytokentype yytoken_kind_t; +#endif +/* Token kinds. */ +#define YYEMPTY -2 +#define YYEOF 0 +#define YYerror 256 +#define YYUNDEF 257 #define CLASS 1 #define RESOURCE 2 #define DATATYPE 3 @@ -50,3 +166,19 @@ #define RBRACE 47 #define STRING 48 #define ERRORTOKEN 49 + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + + +int yyparse (void); + + +#endif /* !YY_YY_WMLPARSE_H_INCLUDED */ diff --git a/ext/src/mcde/motif/tools/wml/wmluiltok.c b/ext/src/mcde/motif/tools/wml/wmluiltok.c index 4b2b69e854..fee00e4405 100644 --- a/ext/src/mcde/motif/tools/wml/wmluiltok.c +++ b/ext/src/mcde/motif/tools/wml/wmluiltok.c @@ -7,8 +7,8 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 39 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -83,60 +83,48 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ -#ifdef __cplusplus +/* begin standard C++ headers. */ -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST +/* TODO: this is always defined, so inline it */ #define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) #else -#define yyconst +#define yynoreturn #endif /* Returned upon end-of-file. */ #define YY_NULL 0 -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * - /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START - /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart(yyin ) - +#define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ @@ -166,14 +154,14 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef size_t yy_size_t; #endif -extern yy_size_t yyleng; +extern int yyleng; extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - + #define YY_LESS_LINENO(n) #define YY_LINENO_REWIND_TO(ptr) @@ -190,7 +178,6 @@ extern FILE *yyin, *yyout; YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) - #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -205,12 +192,12 @@ struct yy_buffer_state /* Size of input buffer in bytes, not including room for EOB * characters. */ - yy_size_t yy_buf_size; + int yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - yy_size_t yy_n_chars; + int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -233,7 +220,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -261,7 +248,7 @@ struct yy_buffer_state /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ +static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general @@ -272,7 +259,6 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) - /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ @@ -280,11 +266,11 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; -static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ -yy_size_t yyleng; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; +static char *yy_c_buf_p = NULL; static int yy_init = 0; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ @@ -293,82 +279,81 @@ static int yy_start = 0; /* start state number */ */ static int yy_did_buffer_switch_on_eof; -void yyrestart (FILE *input_file ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); -void yy_delete_buffer (YY_BUFFER_STATE b ); -void yy_flush_buffer (YY_BUFFER_STATE b ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state (void ); +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void ); -static void yyensure_buffer_stack (void ); -static void yy_load_buffer_state (void ); -static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); +static void yyensure_buffer_stack ( void ); +static void yy_load_buffer_state ( void ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) -#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); -YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ); - -void *yyalloc (yy_size_t ); -void *yyrealloc (void *,yy_size_t ); -void yyfree (void * ); +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * ); #define yy_new_buffer yy_create_buffer - #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } - #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } - #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ -typedef unsigned char YY_CHAR; +#define yywrap() (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +FILE *yyin = NULL, *yyout = NULL; typedef int yy_state_type; extern int yylineno; - int yylineno = 1; extern char *yytext; +#ifdef yytext_ptr +#undef yytext_ptr +#endif #define yytext_ptr yytext -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); +static yy_state_type yy_get_previous_state ( void ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); +static int yy_get_next_buffer ( void ); +static void yynoreturn yy_fatal_error ( const char* msg ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ + yyleng = (int) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; - #define YY_NUM_RULES 7 #define YY_END_OF_BUFFER 8 /* This struct is not used in this scanner, @@ -378,13 +363,13 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[18] = +static const flex_int16_t yy_accept[18] = { 0, 0, 0, 8, 6, 2, 1, 6, 5, 6, 3, 5, 0, 0, 0, 0, 4, 0 } ; -static yyconst flex_int32_t yy_ec[256] = +static const YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -416,25 +401,25 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[13] = +static const YY_CHAR yy_meta[13] = { 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2 } ; -static yyconst flex_int16_t yy_base[19] = +static const flex_int16_t yy_base[19] = { 0, 0, 17, 20, 22, 22, 22, 14, 0, 6, 22, 0, 6, 7, 7, 4, 22, 22, 11 } ; -static yyconst flex_int16_t yy_def[19] = +static const flex_int16_t yy_def[19] = { 0, 17, 1, 17, 17, 17, 17, 17, 18, 17, 17, 18, 17, 17, 17, 17, 17, 0, 17 } ; -static yyconst flex_int16_t yy_nxt[35] = +static const flex_int16_t yy_nxt[35] = { 0, 4, 5, 6, 4, 4, 7, 8, 8, 8, 8, 8, 8, 11, 16, 15, 14, 13, 12, 10, 17, @@ -442,7 +427,7 @@ static yyconst flex_int16_t yy_nxt[35] = 17, 17, 17, 17 } ; -static yyconst flex_int16_t yy_chk[35] = +static const flex_int16_t yy_chk[35] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 18, 15, 14, 13, 12, 9, 7, 3, @@ -518,7 +503,8 @@ char *yytext; * to stdout. */ -#line 59 "wmluiltok.l" +#line 507 "wmluiltok.c" +#line 61 "wmluiltok.l" #include @@ -556,7 +542,8 @@ int in_token = 0; int state = 0; int used = 0; -#line 560 "wmluiltok.c" +#line 546 "wmluiltok.c" +#line 547 "wmluiltok.c" #define INITIAL 0 @@ -572,36 +559,36 @@ int used = 0; #define YY_EXTRA_TYPE void * #endif -static int yy_init_globals (void ); +static int yy_init_globals ( void ); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int yylex_destroy (void ); +int yylex_destroy ( void ); -int yyget_debug (void ); +int yyget_debug ( void ); -void yyset_debug (int debug_flag ); +void yyset_debug ( int debug_flag ); -YY_EXTRA_TYPE yyget_extra (void ); +YY_EXTRA_TYPE yyget_extra ( void ); -void yyset_extra (YY_EXTRA_TYPE user_defined ); +void yyset_extra ( YY_EXTRA_TYPE user_defined ); -FILE *yyget_in (void ); +FILE *yyget_in ( void ); -void yyset_in (FILE * in_str ); +void yyset_in ( FILE * _in_str ); -FILE *yyget_out (void ); +FILE *yyget_out ( void ); -void yyset_out (FILE * out_str ); +void yyset_out ( FILE * _out_str ); -yy_size_t yyget_leng (void ); + int yyget_leng ( void ); -char *yyget_text (void ); +char *yyget_text ( void ); -int yyget_lineno (void ); +int yyget_lineno ( void ); -void yyset_lineno (int line_number ); +void yyset_lineno ( int _line_number ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -609,28 +596,31 @@ void yyset_lineno (int line_number ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int yywrap (void ); +extern "C" int yywrap ( void ); #else -extern int yywrap (void ); +extern int yywrap ( void ); #endif #endif - static void yyunput (int c,char *buf_ptr ); +#ifndef YY_NO_UNPUT + static void yyunput ( int c, char *buf_ptr ); + +#endif + #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy ( char *, const char *, int ); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen ( const char * ); #endif #ifndef YY_NO_INPUT - #ifdef __cplusplus -static int yyinput (void ); +static int yyinput ( void ); #else -static int input (void ); +static int input ( void ); #endif #endif @@ -650,7 +640,7 @@ static int input (void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -674,7 +664,7 @@ static int input (void ); else \ { \ errno=0; \ - while ( (result = fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -729,7 +719,7 @@ extern int yylex (void); /* Code executed at the end of each rule. */ #ifndef YY_BREAK -#define YY_BREAK break; +#define YY_BREAK /*LINTED*/break; #endif #define YY_RULE_SETUP \ @@ -742,9 +732,9 @@ extern int yylex (void); */ YY_DECL { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; if ( !(yy_init) ) { @@ -766,20 +756,20 @@ YY_DECL if ( ! YY_CURRENT_BUFFER ) { yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); } - yy_load_buffer_state( ); + yy_load_buffer_state( ); } { -#line 100 "wmluiltok.l" +#line 102 "wmluiltok.l" -#line 781 "wmluiltok.c" +#line 771 "wmluiltok.c" - while ( 1 ) /* loops until end-of-file is reached */ + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { yy_cp = (yy_c_buf_p); @@ -796,7 +786,7 @@ YY_DECL yy_match: do { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -806,9 +796,9 @@ yy_match: { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 18 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 22 ); @@ -838,7 +828,7 @@ do_action: /* This label is used only to access EOF actions. */ case 1: /* rule 1 can match eol */ YY_RULE_SETUP -#line 103 "wmluiltok.l" +#line 105 "wmluiltok.l" { if (in_token == TRUE) { @@ -851,19 +841,19 @@ YY_RULE_SETUP YY_BREAK case 2: YY_RULE_SETUP -#line 113 "wmluiltok.l" +#line 115 "wmluiltok.l" { /* swallow */ } YY_BREAK case 3: YY_RULE_SETUP -#line 117 "wmluiltok.l" +#line 119 "wmluiltok.l" { /* swallow */ } YY_BREAK case 4: YY_RULE_SETUP -#line 121 "wmluiltok.l" +#line 123 "wmluiltok.l" { in_token = TRUE; state = 0; @@ -871,7 +861,7 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 126 "wmluiltok.l" +#line 128 "wmluiltok.l" { if (in_token == TRUE) { @@ -916,16 +906,16 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 168 "wmluiltok.l" +#line 170 "wmluiltok.l" { /* swallow */ } YY_BREAK case 7: YY_RULE_SETUP -#line 171 "wmluiltok.l" +#line 173 "wmluiltok.l" ECHO; YY_BREAK -#line 929 "wmluiltok.c" +#line 919 "wmluiltok.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1003,7 +993,7 @@ case YY_STATE_EOF(INITIAL): { (yy_did_buffer_switch_on_eof) = 0; - if ( yywrap( ) ) + if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up @@ -1068,9 +1058,9 @@ case YY_STATE_EOF(INITIAL): */ static int yy_get_next_buffer (void) { - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = (yytext_ptr); + int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) @@ -1099,7 +1089,7 @@ static int yy_get_next_buffer (void) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -1126,7 +1116,7 @@ static int yy_get_next_buffer (void) if ( b->yy_is_our_buffer ) { - yy_size_t new_size = b->yy_buf_size * 2; + int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -1135,11 +1125,12 @@ static int yy_get_next_buffer (void) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) ); } else /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; + b->yy_ch_buf = NULL; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( @@ -1167,7 +1158,7 @@ static int yy_get_next_buffer (void) if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin ); + yyrestart( yyin ); } else @@ -1181,12 +1172,15 @@ static int yy_get_next_buffer (void) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); } (yy_n_chars) += number_to_move; @@ -1202,15 +1196,15 @@ static int yy_get_next_buffer (void) static yy_state_type yy_get_previous_state (void) { - register yy_state_type yy_current_state; - register char *yy_cp; + yy_state_type yy_current_state; + char *yy_cp; yy_current_state = (yy_start); yy_current_state += YY_AT_BOL(); for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -1220,9 +1214,9 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 18 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; } return yy_current_state; @@ -1235,10 +1229,10 @@ static int yy_get_next_buffer (void) */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) { - register int yy_is_jam; - register char *yy_cp = (yy_c_buf_p); + int yy_is_jam; + char *yy_cp = (yy_c_buf_p); - register YY_CHAR yy_c = 1; + YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -1248,17 +1242,19 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 18 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; yy_is_jam = (yy_current_state == 17); return yy_is_jam ? 0 : yy_current_state; } - static void yyunput (int c, register char * yy_bp ) +#ifndef YY_NO_UNPUT + + static void yyunput (int c, char * yy_bp ) { - register char *yy_cp; + char *yy_cp; yy_cp = (yy_c_buf_p); @@ -1268,10 +1264,10 @@ static int yy_get_next_buffer (void) if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - register yy_size_t number_to_move = (yy_n_chars) + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + int number_to_move = (yy_n_chars) + 2; + char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = + char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) @@ -1280,7 +1276,7 @@ static int yy_get_next_buffer (void) yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + (yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); @@ -1293,6 +1289,8 @@ static int yy_get_next_buffer (void) (yy_c_buf_p) = yy_cp; } +#endif + #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (void) @@ -1317,7 +1315,7 @@ static int yy_get_next_buffer (void) else { /* need more input */ - yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) @@ -1334,14 +1332,14 @@ static int yy_get_next_buffer (void) */ /* Reset buffer status. */ - yyrestart(yyin ); + yyrestart( yyin ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( yywrap( ) ) - return EOF; + if ( yywrap( ) ) + return 0; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; @@ -1380,11 +1378,11 @@ static int yy_get_next_buffer (void) if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); } - yy_init_buffer(YY_CURRENT_BUFFER,input_file ); - yy_load_buffer_state( ); + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); } /** Switch to a different input buffer. @@ -1412,7 +1410,7 @@ static int yy_get_next_buffer (void) } YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( ); + yy_load_buffer_state( ); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag @@ -1440,7 +1438,7 @@ static void yy_load_buffer_state (void) { YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); @@ -1449,13 +1447,13 @@ static void yy_load_buffer_state (void) /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - yy_init_buffer(b,file ); + yy_init_buffer( b, file ); return b; } @@ -1474,9 +1472,9 @@ static void yy_load_buffer_state (void) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - yyfree((void *) b->yy_ch_buf ); + yyfree( (void *) b->yy_ch_buf ); - yyfree((void *) b ); + yyfree( (void *) b ); } /* Initializes or reinitializes a buffer. @@ -1488,7 +1486,7 @@ static void yy_load_buffer_state (void) { int oerrno = errno; - yy_flush_buffer(b ); + yy_flush_buffer( b ); b->yy_input_file = file; b->yy_fill_buffer = 1; @@ -1531,7 +1529,7 @@ static void yy_load_buffer_state (void) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( ); + yy_load_buffer_state( ); } /** Pushes the new state onto the stack. The new state becomes @@ -1562,7 +1560,7 @@ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } @@ -1581,7 +1579,7 @@ void yypop_buffer_state (void) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } @@ -1599,15 +1597,15 @@ static void yyensure_buffer_stack (void) * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; @@ -1616,7 +1614,7 @@ static void yyensure_buffer_stack (void) if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; + yy_size_t grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc @@ -1636,7 +1634,7 @@ static void yyensure_buffer_stack (void) * @param base the character buffer * @param size the size in bytes of the character buffer * - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) { @@ -1646,23 +1644,23 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ - return 0; + return NULL; - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; - b->yy_input_file = 0; + b->yy_input_file = NULL; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - yy_switch_to_buffer(b ); + yy_switch_to_buffer( b ); return b; } @@ -1675,10 +1673,10 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ -YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) +YY_BUFFER_STATE yy_scan_string (const char * yystr ) { - return yy_scan_bytes(yystr,strlen(yystr) ); + return yy_scan_bytes( yystr, (int) strlen(yystr) ); } /** Setup the input buffer state to scan the given bytes. The next call to yylex() will @@ -1688,16 +1686,16 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) { YY_BUFFER_STATE b; char *buf; yy_size_t n; - yy_size_t i; + int i; /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) yyalloc(n ); + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); @@ -1706,7 +1704,7 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = yy_scan_buffer(buf,n ); + b = yy_scan_buffer( buf, n ); if ( ! b ) YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); @@ -1722,9 +1720,9 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg ) +static void yynoreturn yy_fatal_error (const char* msg ) { - (void) fprintf( stderr, "%s\n", msg ); + fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -1752,7 +1750,7 @@ static void yy_fatal_error (yyconst char* msg ) */ int yyget_lineno (void) { - + return yylineno; } @@ -1775,7 +1773,7 @@ FILE *yyget_out (void) /** Get the length of the current token. * */ -yy_size_t yyget_leng (void) +int yyget_leng (void) { return yyleng; } @@ -1790,29 +1788,29 @@ char *yyget_text (void) } /** Set the current line number. - * @param line_number + * @param _line_number line number * */ -void yyset_lineno (int line_number ) +void yyset_lineno (int _line_number ) { - yylineno = line_number; + yylineno = _line_number; } /** Set the input stream. This does not discard the current * input buffer. - * @param in_str A readable stream. + * @param _in_str A readable stream. * * @see yy_switch_to_buffer */ -void yyset_in (FILE * in_str ) +void yyset_in (FILE * _in_str ) { - yyin = in_str ; + yyin = _in_str ; } -void yyset_out (FILE * out_str ) +void yyset_out (FILE * _out_str ) { - yyout = out_str ; + yyout = _out_str ; } int yyget_debug (void) @@ -1820,9 +1818,9 @@ int yyget_debug (void) return yy_flex_debug; } -void yyset_debug (int bdebug ) +void yyset_debug (int _bdebug ) { - yy_flex_debug = bdebug ; + yy_flex_debug = _bdebug ; } static int yy_init_globals (void) @@ -1831,10 +1829,10 @@ static int yy_init_globals (void) * This function is called from yylex_destroy(), so don't allocate here. */ - (yy_buffer_stack) = 0; + (yy_buffer_stack) = NULL; (yy_buffer_stack_top) = 0; (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; + (yy_c_buf_p) = NULL; (yy_init) = 0; (yy_start) = 0; @@ -1843,8 +1841,8 @@ static int yy_init_globals (void) yyin = stdin; yyout = stdout; #else - yyin = (FILE *) 0; - yyout = (FILE *) 0; + yyin = NULL; + yyout = NULL; #endif /* For future reference: Set errno on error, since we are called by @@ -1859,7 +1857,7 @@ int yylex_destroy (void) /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - yy_delete_buffer(YY_CURRENT_BUFFER ); + yy_delete_buffer( YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; yypop_buffer_state(); } @@ -1880,18 +1878,19 @@ int yylex_destroy (void) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +static void yy_flex_strncpy (char* s1, const char * s2, int n ) { - register int i; + + int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) +static int yy_flex_strlen (const char * s ) { - register int n; + int n; for ( n = 0; s[n]; ++n ) ; @@ -1901,11 +1900,12 @@ static int yy_flex_strlen (yyconst char * s ) void *yyalloc (yy_size_t size ) { - return (void *) malloc( size ); + return malloc(size); } void *yyrealloc (void * ptr, yy_size_t size ) { + /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter @@ -1913,18 +1913,27 @@ void *yyrealloc (void * ptr, yy_size_t size ) * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ - return (void *) realloc( (char *) ptr, size ); + return realloc(ptr, size); } void yyfree (void * ptr ) { - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" -#line 170 "wmluiltok.l" +int main (void); +int main () +{ + + yylex(); + + return 0; +} + +#line 173 "wmluiltok.l" diff --git a/ext/src/mcde/pkgsrc-motif/Makefile b/ext/src/mcde/pkgsrc-motif/Makefile index 6a0f3b21e8..05df4e0728 100644 --- a/ext/src/mcde/pkgsrc-motif/Makefile +++ b/ext/src/mcde/pkgsrc-motif/Makefile @@ -75,7 +75,8 @@ MAKE_FLAGS+= CC_FOR_BUILD=${NATIVE_CC:Q:U${CC:Q}} # cross gcc defaults to C17, measured: __STDC_VERSION__ 201710L). # :Q is required -- without it make reads -std=gnu17 as an option of its own # ("invalid option -- '='", userland-2026-11-13x.log:396). -CFLAGS_FOR_BUILD= -O2 -std=gnu17 +# the host's flags, from tools/pkgsrc-cross.mk.conf +CFLAGS_FOR_BUILD= ${HOST_BUILD_CFLAGS} MAKE_FLAGS+= CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD:Q} # wmluiltok is a host tool that links -lfl (wmluiltok_LDADD in tools/wml/Makefile). # In a cross build -L${LOCALBASE}/lib is rewritten to the buildlink directory, so @@ -84,7 +85,8 @@ MAKE_FLAGS+= CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD:Q} # build/logs/userland-2026-11-14a.log:3678ff). The bootstrap prefix has a host # libfl.a; naming the file leaves no search path to pick the target's from. .if ${USE_CROSS_COMPILE:U:tl} == "yes" -MAKE_FLAGS+= wmluiltok_LDADD=${MAKRONIX_TOP:Q}/build/pkg/lib/libfl.a +# the host's flex archive, named in tools/pkgsrc-cross.mk.conf +MAKE_FLAGS+= wmluiltok_LDADD=${HOST_FL_A:Q} .endif MAKE_FLAGS+= AR_FOR_BUILD=${NATIVE_AR:Q:U${AR:Q}} MAKE_FLAGS+= RANLIB_FOR_BUILD=${NATIVE_RANLIB:Q:U${RANLIB:Q}} @@ -98,10 +100,9 @@ MAKE_FLAGS+= LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD:Q} # the static archives there are named directly, which no search path can # redirect to the target's. .if ${USE_CROSS_COMPILE:U:tl} == "yes" -LIBS_FOR_BUILD= ${MAKRONIX_TOP:Q}/build/pkg/lib/libXt.a \ - ${MAKRONIX_TOP:Q}/build/pkg/lib/libX11.a \ - ${MAKRONIX_TOP:Q}/build/pkg/lib/libSM.a \ - ${MAKRONIX_TOP:Q}/build/pkg/lib/libICE.a +# The host tool links the X of the build host; which one that is, is named in +# tools/pkgsrc-cross.mk.conf (HOST_X11_LIBS) -- not decided here. +LIBS_FOR_BUILD= ${HOST_X11_LIBS} .else LIBS_FOR_BUILD= -lXt .endif @@ -133,7 +134,14 @@ LDFLAGS_FOR_BUILD+= ${BUILDLINK_LDFLAGS} .else MAKE_FLAGS+= CROSS_COMPILING=yes # XXX should support independent cross PREFIX -CPPFLAGS_FOR_BUILD+= -I${PREFIX:Q}/include +# PREFIX is the target's (/usr/pkg). Where the build host has an X of its own, +# the build tools (makestrs, wml, wmldbcreate) must see THAT one: on Makronix +# /usr/pkg/include has no X11, and makestrs stopped with "X11/Xos.h: No such +# file or directory" (measured 2026-11-20 on makronix-build). On a Linux host +# /usr/X11R7 does not exist and the buildlink's PREFIX/include is the answer, +# as before. +# the include path of the host's X, from tools/pkgsrc-cross.mk.conf +CPPFLAGS_FOR_BUILD+= -I${HOST_X11BASE:Q}/include LDFLAGS_FOR_BUILD+= -L${PREFIX:Q}/lib LDFLAGS_FOR_BUILD+= ${COMPILER_RPATH_FLAG:Q}${PREFIX:Q}/lib CONFIGURE_ARGS.NetBSD+= ac_cv_file__usr_X_include_X11_X_h=no diff --git a/ext/src/mcde/pkgsrc-motif/distinfo b/ext/src/mcde/pkgsrc-motif/distinfo index 464d4599ce..80116bfe74 100644 --- a/ext/src/mcde/pkgsrc-motif/distinfo +++ b/ext/src/mcde/pkgsrc-motif/distinfo @@ -1,5 +1,5 @@ $NetBSD$ -BLAKE2s (mcde-0.1.0.tar.gz) = 8ca5f20642e38ee7fa47a01df0d7f577380a57af2ea920eb6aae5800e5809231 -SHA512 (mcde-0.1.0.tar.gz) = 94d52fd24cc58007d128c267e16a1c42a1728765e1ec5d4d73e3d460d986fe29312a813ef31c950de022f413874576430b30e426bf7ff5bed34e70a10651c5c4 -Size (mcde-0.1.0.tar.gz) = 67002854 bytes +BLAKE2s (mcde-0.1.0.tar.gz) = 6f45b4311eee148ede12dedfef4948211a1f682ca82f2cedd36b09a7896c0efa +SHA512 (mcde-0.1.0.tar.gz) = fc0dd9bd58f9b1901d37c772d241b7fad64033f2d5cfc205957d4eea217778ab429487dfb7bccee3824fc4b7506cbb146e9c5bf60d51a8d61a04053d01af7371 +Size (mcde-0.1.0.tar.gz) = 66938753 bytes diff --git a/ext/src/mcde/pkgsrc/Makefile b/ext/src/mcde/pkgsrc/Makefile index ea0095a268..de1ac94cd5 100644 --- a/ext/src/mcde/pkgsrc/Makefile +++ b/ext/src/mcde/pkgsrc/Makefile @@ -149,8 +149,11 @@ PLIST.tttypes= yes .if ${USE_CROSS_COMPILE:U:tl} == "yes" # the build tools are 1990s C, and this host's compiler defaults to C23 (see the # Motif recipe's CFLAGS_FOR_BUILD) -CFLAGS_FOR_BUILD= -O2 -std=gnu17 +# the host's flags, from tools/pkgsrc-cross.mk.conf +CFLAGS_FOR_BUILD= ${HOST_BUILD_CFLAGS} CPPFLAGS_FOR_BUILD= -DHAVE_FCNTL_H +# the include path of the host's X, from tools/pkgsrc-cross.mk.conf +CPPFLAGS_FOR_BUILD+= -I${HOST_X11BASE:Q}/include # Nothing of the target in what links a build tool: no -L/-R of the sysroot, and # not the X_LIBS configure would add (a bare -R, which the host's gcc rejects: # build/logs/mcde-hosttools-2026-11-14b.log, "unrecognized command-line option -R"). diff --git a/ext/src/mcde/pkgsrc/distinfo b/ext/src/mcde/pkgsrc/distinfo index 464d4599ce..80116bfe74 100644 --- a/ext/src/mcde/pkgsrc/distinfo +++ b/ext/src/mcde/pkgsrc/distinfo @@ -1,5 +1,5 @@ $NetBSD$ -BLAKE2s (mcde-0.1.0.tar.gz) = 8ca5f20642e38ee7fa47a01df0d7f577380a57af2ea920eb6aae5800e5809231 -SHA512 (mcde-0.1.0.tar.gz) = 94d52fd24cc58007d128c267e16a1c42a1728765e1ec5d4d73e3d460d986fe29312a813ef31c950de022f413874576430b30e426bf7ff5bed34e70a10651c5c4 -Size (mcde-0.1.0.tar.gz) = 67002854 bytes +BLAKE2s (mcde-0.1.0.tar.gz) = 6f45b4311eee148ede12dedfef4948211a1f682ca82f2cedd36b09a7896c0efa +SHA512 (mcde-0.1.0.tar.gz) = fc0dd9bd58f9b1901d37c772d241b7fad64033f2d5cfc205957d4eea217778ab429487dfb7bccee3824fc4b7506cbb146e9c5bf60d51a8d61a04053d01af7371 +Size (mcde-0.1.0.tar.gz) = 66938753 bytes diff --git a/ext/src/mcde/programs/dtbar/dtbar.c b/ext/src/mcde/programs/dtbar/dtbar.c index 8fd0e43ce1..558a3c6386 100644 --- a/ext/src/mcde/programs/dtbar/dtbar.c +++ b/ext/src/mcde/programs/dtbar/dtbar.c @@ -1413,20 +1413,23 @@ Events(Widget w, XtPointer data, XEvent *ev, Boolean *cont) /* the program brings its menus up to date before one opens */ if (ev->xcrossing.window == XtWindow(shell)) Send(aRefresh, 0, 0); - /* A client straight onto the bar is no window crossing for - * dtwm, so the terminal kept the focus over the bar (t0255). - * The bar is not a text window: the focus goes to the - * pointer root, and dtwm clears the active client. */ - if (ev->xcrossing.window == XtWindow(shell) && - ev->xcrossing.mode == NotifyNormal) { - Window f = None; - int revert = 0; + /* The bar is no focus target (t0255, t0257): moving the + * pointer onto it must not take the keyboard away from the + * program whose menu the bar shows. The bar says so on its + * own window (_MCDE_NO_FOCUS) and leaves the focus alone; its + * menus open with the pointer, and an item acts on the client + * the menu came from, not on whatever has the X focus. */ + break; + case MapNotify: + /* tell dtwm not to give the keyboard to the bar (see + * EnterNotify): focus follows the pointer elsewhere, and the + * bar keeps the last program's menu */ + if (ev->xmap.window == XtWindow(shell)) { + Atom a = XInternAtom(dpy, "_MCDE_NO_FOCUS", False); + long one = 1; - XGetInputFocus(dpy, &f, &revert); - if (f != PointerRoot && f != None && - f != XtWindow(shell)) - XSetInputFocus(dpy, PointerRoot, - RevertToPointerRoot, ev->xcrossing.time); + XChangeProperty(dpy, XtWindow(shell), a, XA_CARDINAL, + 32, PropModeReplace, (unsigned char *) &one, 1); } break; case VisibilityNotify: diff --git a/ext/src/mcde/programs/dtphoto/dtphoto.c b/ext/src/mcde/programs/dtphoto/dtphoto.c index 227cffaaed..283044e204 100644 --- a/ext/src/mcde/programs/dtphoto/dtphoto.c +++ b/ext/src/mcde/programs/dtphoto/dtphoto.c @@ -20,6 +20,7 @@ #include #include #include +#include /* strcasecmp: the ending decides the writer */ #include #include #include @@ -53,6 +54,14 @@ #include #include +/* M_PI is not in POSIX: math.h only carries it for _XOPEN_SOURCE or + * _NETBSD_SOURCE, and _POSIX_C_SOURCE 200809L (line 16) turns both off. + * The value is the one every libm has; the guard keeps quiet where the + * header defines it. Same as lib/McdeSys/test_audio.c does. */ +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + #define MAXMENUS 16 #define MAXITEMS 80 #define MAXDEPTH 4 @@ -76,7 +85,7 @@ struct Menu { enum { CMD_NONE, CMD_NEW, CMD_OPEN, CMD_SAVE, CMD_SAVEAS, CMD_QUIT, - CMD_UNDO, CMD_ZOOMIN, CMD_ZOOMOUT, CMD_FIT, CMD_ACTUAL, + CMD_UNDO, CMD_REDO, CMD_ZOOMIN, CMD_ZOOMOUT, CMD_FIT, CMD_ACTUAL, CMD_ALL, CMD_DESELECT, CMD_CLEAR, CMD_FILL, CMD_CROP, CMD_INVERSE, /* Select > Modify: morphology on the mask */ CMD_FEATHER, CMD_SELBORDER, CMD_SELSMOOTH, CMD_SELEXPAND, @@ -198,7 +207,8 @@ static int eraserRadius = 6; static int wandTolerance = 32; /* the wand, and Grow/Similar */ static int retouchRadius = 6; static int retouchStrength = 60; -static int undoDepth = 1; /* how many steps Undo keeps */ +static int undoDepth = 8; /* how many steps Undo keeps */ + static char *docPath; /* the file the document came from, or NULL */ /* * Publisher Options. An EPS carries its size in points (1/72 inch), so a @@ -249,6 +259,17 @@ static void DrawMarquee(Window win, int ox, int oy); static void MaskClear(void); static int MaskCover(int x, int y); static void RenderDoc(Widget w); +/* the undo history: declared here because the file, the menu and the + * canvas all record a state before they change the picture */ +static void UndoRecord(void); +static void UndoReset(void); +static void UndoForget(void); +static int MaskAlloc(void); +static int MaskGet(int x, int y); +static int MaskTransform(int flip, int turn); +static int MaskShift(int nw, int nh, int dx, int dy); +/* the mask was already moved to the new size, so SetImageRGB keeps it */ +static int maskSized; static void TypeIntoImage(int x, int y); static void SetZoom(int z); static void MoveMasked(int dx, int dy); @@ -275,6 +296,17 @@ typedef struct { static Layer layers[MAXLAYERS]; static int nlayers, curLayer, layerW, layerH; +/* + * The PSD reader and writer live above the stack's own code (the file + * reader comes before it in this file), so the four functions they call + * are declared here. LayerEnsure has a second declaration further down + * next to the stack itself; both say the same thing. + */ +static void LayerInvalidate(void); +static void LayerEnsure(void); +static void LayerSync(void); +static int LayerComposite(unsigned char **outp); + /* the hand: move the view, not the picture */ static void PanBy(int dx, int dy) @@ -497,8 +529,8 @@ SetImageRGB(const unsigned char *rgb, int w, int h) * Copying here mid-drag would leave the last intermediate frame in * snap instead (a moved picture could not be undone). */ - if (same && !dragging && image != None && snap != None) - XCopyArea(dpy, image, snap, gc, 0, 0, docW, docH, 0, 0); + if (same && !dragging) + UndoRecord(); docW = w; docH = h; /* @@ -506,12 +538,14 @@ SetImageRGB(const unsigned char *rgb, int w, int h) * without one. A same-size change keeps it: Invert and Desaturate * leave everything where it was, and the selection stays valid. */ - if (!same) { + if (!same && !maskSized) { MaskClear(); free(selMask); selMask = NULL; selMaskSize = 0; } + /* a transform prepared the mask for the new size; it is spent now */ + maskSized = 0; /* the pixmaps are already the right size when nothing changed */ if (!same || image == None) NewPixmaps(); @@ -577,6 +611,11 @@ SetImageRGB(const unsigned char *rgb, int w, int h) XPutImage(dpy, image, gc, im, 0, 0, 0, 0, (unsigned int) w, (unsigned int) h); XDestroyImage(im); + /* + * `snap` follows the new picture: it is the frame the canvas tools + * copy and the state Undo returns to. The history itself was + * pushed by UndoRecord() *before* this write, so nothing is lost. + */ XCopyArea(dpy, image, snap, gc, 0, 0, docW, docH, 0, 0); return 0; } @@ -1276,17 +1315,1746 @@ PublishEPS(void) return r; } +/* --------------------------------------------------------------- psd files */ +/* + * A Photoshop file, so a document with layers does not lose them. It is the + * format this program is a copy of, and the only one of its writers (PNG, + * BMP, JPEG, GIF, XPM -- each a flat image) that can carry a stack. + * + * Measured against files ImageMagick writes (2026-11-22), not against + * memory, because three details are easy to get wrong and each one slides + * everything after it: + * + * - the length of a layer's channel data *includes* its two-byte + * compression field; + * - a layer has its own rectangle, which may be smaller than the canvas + * and sits at an offset (a 4x4 layer in an 8x8 document is normal); + * - the name inside a layer's extra data is padded to a four-byte + * boundary *of that section*, not of the file. The header puts the + * section at 26 bytes, so padding on the file offset shifts every + * record behind it. + * + * Compression: 0 (raw) and 1 (packbits) -- what Photoshop 2.5 and 3 wrote + * and read. A zip-compressed file (4.0 and later) is refused with a + * message rather than read as garbage. + */ + +/* the bytes of a file grow in one buffer, so a length can be patched later */ +typedef struct { + unsigned char *p; + size_t len, cap; + int fail; +} PSDOut; + +static void +PsdPut(PSDOut *o, const void *src, size_t n) +{ + if (o->fail) + return; + if (o->len + n > o->cap) { + size_t want = o->cap == 0 ? 65536 : o->cap; + unsigned char *np; + + while (want < o->len + n) + want *= 2; + np = realloc(o->p, want); + if (np == NULL) { + o->fail = 1; + return; + } + o->p = np; + o->cap = want; + } + memcpy(o->p + o->len, src, n); + o->len += n; +} + +static void +PsdByte(PSDOut *o, unsigned v) +{ + unsigned char b = (unsigned char) (v & 0xff); + + PsdPut(o, &b, 1); +} + +static void +PsdBE16(PSDOut *o, unsigned v) +{ + unsigned char b[2]; + + b[0] = (unsigned char) ((v >> 8) & 0xff); + b[1] = (unsigned char) (v & 0xff); + PsdPut(o, b, 2); +} + +static void +PsdBE32(PSDOut *o, unsigned long v) +{ + unsigned char b[4]; + + b[0] = (unsigned char) ((v >> 24) & 0xff); + b[1] = (unsigned char) ((v >> 16) & 0xff); + b[2] = (unsigned char) ((v >> 8) & 0xff); + b[3] = (unsigned char) (v & 0xff); + PsdPut(o, b, 4); +} + +/* a four-byte length written as zero, patched once its body is in */ +static size_t +PsdMark(PSDOut *o) +{ + size_t at = o->len; + + PsdBE32(o, 0); + return at; +} + +static void +PsdFix(PSDOut *o, size_t at) +{ + unsigned long v; + + if (o->fail) + return; + v = (unsigned long) (o->len - at - 4); + o->p[at] = (unsigned char) ((v >> 24) & 0xff); + o->p[at + 1] = (unsigned char) ((v >> 16) & 0xff); + o->p[at + 2] = (unsigned char) ((v >> 8) & 0xff); + o->p[at + 3] = (unsigned char) (v & 0xff); +} + +static void +PsdPascal(PSDOut *o, const char *s, size_t base) +{ + size_t n = strlen(s); + + if (n > 255) + n = 255; + PsdByte(o, (unsigned) n); + PsdPut(o, s, n); + while (((o->len - base) % 4) != 0) + PsdByte(o, 0); +} + +static const char * +PsdBlendKey(int mode) +{ + return mode == 1 ? "mul " : (mode == 2 ? "scrn" : "norm"); +} + +static int +PsdBlendMode(const unsigned char *key) +{ + if (memcmp(key, "mul ", 4) == 0) + return 1; + if (memcmp(key, "scrn", 4) == 0) + return 2; + return 0; +} + +static int +PsdEndsWith(const char *path, const char *ending) +{ + size_t a = strlen(path), b = strlen(ending); + size_t i; + + if (a <= b) + return 0; + for (i = 0; i < b; i++) { + int c = (unsigned char) path[a - b + i]; + + if (c >= 'A' && c <= 'Z') + c += 'a' - 'A'; + if (c != ending[i]) + return 0; + } + return 1; +} + +/* --- the reader: a cursor over the whole file, bounds-checked --- */ + +typedef struct { + const unsigned char *p; + size_t len, at; + int bad; +} PSDIn; + +static unsigned +PsdRByte(PSDIn *i) +{ + if (i->bad || i->at + 1 > i->len) { + i->bad = 1; + return 0; + } + return i->p[i->at++]; +} + +static unsigned +PsdRBE16(PSDIn *i) +{ + unsigned a = PsdRByte(i), b = PsdRByte(i); + + return (a << 8) | b; +} + +static unsigned long +PsdRBE32(PSDIn *i) +{ + unsigned long a = PsdRByte(i), b = PsdRByte(i); + unsigned long c = PsdRByte(i), d = PsdRByte(i); + + return (a << 24) | (b << 16) | (c << 8) | d; +} + +static void +PsdSkip(PSDIn *i, unsigned long n) +{ + if (i->bad || (size_t) n > i->len || i->at + n > i->len) { + i->bad = 1; + return; + } + i->at += n; +} + +static const unsigned char * +PsdTake(PSDIn *i, unsigned long n) +{ + const unsigned char *at; + + if (i->bad || (size_t) n > i->len || i->at + n > i->len) { + i->bad = 1; + return NULL; + } + at = i->p + i->at; + i->at += n; + return at; +} + +/* + * One plane of w*h bytes, raw or packbits. `end` is where the plane has to + * stop; the caller knows it from the channel's length field, and it is the + * only honest bound: a corrupt run count must not walk into the next + * channel. + */ +/* + * PackBits, the compression Photoshop 2.5 and 3 write by default: a run of + * three or more equal bytes becomes (2 - n, value) with n up to 128, anything + * else a literal run of up to 128 with the count as (n - 1). The decoder is + * PsdReadPlane above; writing raw only would leave it untested against a + * file this program produced. + * + * A row is written separately because the format stores each row's own + * length in front of it, so a reader can skip a row it does not need. + */ +static size_t +PsdPackRow(const unsigned char *src, int w, unsigned char *out) +{ + int x = 0; + size_t o = 0; + + while (x < w) { + int run = 1; + + while (x + run < w && run < 128 && src[x + run] == src[x]) + run++; + if (run >= 3) { + /* the header of a repeat is 1 - count, so a run of + * 128 is 0x81 and a run of 3 is 0xFE; the decoder + * (PsdReadPlane) computes 1 - c back */ + out[o++] = (unsigned char) (1 - run); + out[o++] = src[x]; + x += run; + continue; + } + /* a literal run, stopped as soon as three equal bytes begin */ + { + int start = x; + + x += run; + while (x < w && x - start < 128) { + int r = 1; + + while (x + r < w && r < 128 && + src[x + r] == src[x]) + r++; + if (r >= 3) + break; + x += r; + } + { + int n = x - start; + + out[o++] = (unsigned char) (n - 1); + memcpy(out + o, src + start, (size_t) n); + o += (size_t) n; + } + } + } + return o; +} + +/* + * What PsdWritePlane will write, in bytes, without writing it. The layer + * record needs the length of every channel before the channel data exists, + * so the two have to agree exactly: this is the same decision, once as a + * count and once as bytes. Keep them together. + */ +static size_t +PsdPlaneSize(const unsigned char *plane, int w, int h) +{ + unsigned char *row; + size_t total = 0; + int y, useRle = 1; + + if ((row = malloc((size_t) w + (size_t) w / 128 + 3)) == NULL) + return 2 + (size_t) w * h; /* the raw fallback */ + for (y = 0; y < h; y++) { + size_t n = PsdPackRow(plane + (size_t) y * w, w, row); + + if (n > (size_t) w + (size_t) w / 128) + useRle = 0; + total += n + 2; + } + free(row); + if (!useRle || total >= (size_t) w * h + 2) + return 2 + (size_t) w * h; + /* the compression word itself is part of the channel's length: + * PsdWritePlane writes it before the first row, and a reader that + * were not told about it would stop two bytes short */ + return 2 + total; +} + +static void +PsdWritePlane(PSDOut *o, const unsigned char *plane, int w, int h) +{ + unsigned char *row; + size_t *rowLen; + int y, useRle = 1; + size_t total = 0; + + /* + * PackBits can grow a row by one byte per 128, so the worst case is + * w + (w / 128) + 2 (the length word) per row. If the packed form is + * not smaller the row is written raw instead -- the format allows a + * mix only per channel, so this decides once for the whole plane. + */ + if ((row = malloc((size_t) w + (size_t) w / 128 + 3)) == NULL || + (rowLen = malloc(sizeof *rowLen * (size_t) h)) == NULL) { + free(row); + free(rowLen); + o->fail = 1; + return; + } + for (y = 0; y < h; y++) { + size_t n = PsdPackRow(plane + (size_t) y * w, w, row); + + if (n > (size_t) w + (size_t) w / 128) + useRle = 0; + total += n + 2; + } + if (!useRle || total >= (size_t) w * h + 2) { + free(rowLen); + free(row); + PsdBE16(o, 0); + PsdPut(o, plane, (size_t) w * h); + return; + } + PsdBE16(o, 1); + /* + * The format puts every row's length first and the rows after them, + * not a length in front of each row. Writing the two interleaved + * reads back fine with a decoder that makes the same mistake, and + * fails in every other reader -- measured with ImageMagick, which + * answers "InvalidLength" for the interleaved form. + */ + for (y = 0; y < h; y++) { + rowLen[y] = PsdPackRow(plane + (size_t) y * w, w, row); + PsdBE16(o, (unsigned) rowLen[y]); + (void) row; + } + for (y = 0; y < h; y++) { + PsdPackRow(plane + (size_t) y * w, w, row); + PsdPut(o, row, rowLen[y]); + } + free(rowLen); + free(row); +} + +static int +PsdReadPlane(PSDIn *i, unsigned char *out, int w, int h, int compression, + size_t end) +{ + unsigned long *rowLen; + int y; + + if (compression == 0) { + const unsigned char *src; + + if ((size_t) w * h > end - i->at) + return -1; + src = PsdTake(i, (unsigned long) w * h); + if (src == NULL) + return -1; + memcpy(out, src, (size_t) w * h); + return 0; + } + if (compression != 1) + return -1; /* zip: 4.0 and later, not this reader */ + /* + * Every row's length comes in one block, the rows follow it. A reader + * that expects a length before each row walks off into the pixel data + * after the first row -- and a writer that does the same agrees with + * it, so neither notices. ImageMagick does. + */ + if ((rowLen = malloc(sizeof *rowLen * (size_t) h)) == NULL) + return -1; + for (y = 0; y < h; y++) { + rowLen[y] = PsdRBE16(i); + if (i->bad || (size_t) rowLen[y] > end - i->at) { + free(rowLen); + return -1; + } + } + for (y = 0; y < h; y++) { + unsigned long n = rowLen[y]; + const unsigned char *src; + unsigned long k = 0; + int x = 0; + + src = PsdTake(i, n); + if (src == NULL) { + free(rowLen); + return -1; + } + while (k < n && x < w) { + int c = (signed char) src[k++]; + + if (c >= 0) { + int run = c + 1; + + while (run-- > 0 && x < w && k < n) + out[(size_t) y * w + x++] = src[k++]; + } else if (c != -128) { + int run = 1 - c; + unsigned char v; + + if (k >= n) + break; + v = src[k++]; + while (run-- > 0 && x < w) + out[(size_t) y * w + x++] = v; + } + } + } + free(rowLen); + return 0; +} + +/* + * A PSD into the layer stack. A file without layer info is a valid PSD (a + * flat picture) and arrives as one layer, which is what it is. + */ +static int +OpenPSD(const char *path) +{ + FILE *f; + unsigned char *buf; + size_t size; + PSDIn in; + int w, h, channels, depth, mode, nrec, i, ch, y, x; + int haveLayers = 0, bad = 0; + + if ((f = fopen(path, "rb")) == NULL) + return -1; + if (fseek(f, 0, SEEK_END) != 0 || (size = (size_t) ftell(f)) < 26 || + fseek(f, 0, SEEK_SET) != 0) { + fclose(f); + return -1; + } + if ((buf = malloc(size)) == NULL) { + fclose(f); + return -1; + } + if (fread(buf, 1, size, f) != size) { + fclose(f); + free(buf); + return -1; + } + fclose(f); + + in.p = buf; + in.len = size; + in.at = 0; + in.bad = 0; + { + const unsigned char *sig = PsdTake(&in, 4); + + if (sig == NULL || memcmp(sig, "8BPS", 4) != 0 || + PsdRBE16(&in) != 1) { + free(buf); + return -1; + } + } + PsdSkip(&in, 6); /* reserved */ + channels = (int) PsdRBE16(&in); + h = (int) PsdRBE32(&in); + w = (int) PsdRBE32(&in); + depth = (int) PsdRBE16(&in); + mode = (int) PsdRBE16(&in); + PsdSkip(&in, PsdRBE32(&in)); /* colour mode data */ + PsdSkip(&in, PsdRBE32(&in)); /* image resources */ + if (in.bad || w <= 0 || h <= 0 || w > 8192 || h > 8192 || + depth != 8 || mode != 3 || channels < 3) { + fprintf(stderr, "dtphoto: %s is not an 8-bit RGB Photoshop file\n", + path); + free(buf); + return -1; + } + + { + unsigned long lmLen = PsdRBE32(&in); + size_t lmEnd = in.at + lmLen; + + if (in.bad || lmEnd > size) { + free(buf); + return -1; + } + if (lmLen > 4) { + unsigned long liLen = PsdRBE32(&in); + size_t liEnd = in.at + liLen; + + if (in.bad || liEnd > lmEnd) { + free(buf); + return -1; + } + /* signed: a negative count means the merged image + * carries the document's own transparency */ + nrec = (int) PsdRBE16(&in); + if (nrec > 32767) + nrec -= 65536; + if (nrec < 0) + nrec = -nrec; + if (nrec > MAXLAYERS) { + fprintf(stderr, "dtphoto: %s has %d layers, the " + "stack holds %d\n", path, nrec, MAXLAYERS); + free(buf); + return -1; + } + if (nrec > 0) { + static struct { + int t, l, b, r, nch; + int cid[8]; + unsigned long clen[8]; + int opacity, hidden, mode2; + char name[48]; + } rec[MAXLAYERS]; + size_t dataAt; + + memset(rec, 0, sizeof rec); + for (i = 0; i < nrec && !in.bad; i++) { + int k; + + rec[i].t = (int) PsdRBE32(&in); + rec[i].l = (int) PsdRBE32(&in); + rec[i].b = (int) PsdRBE32(&in); + rec[i].r = (int) PsdRBE32(&in); + rec[i].nch = (int) PsdRBE16(&in); + if (rec[i].nch < 1 || rec[i].nch > 8) { + in.bad = 1; + break; + } + for (k = 0; k < rec[i].nch; k++) { + rec[i].cid[k] = (int) (short) + PsdRBE16(&in); + rec[i].clen[k] = PsdRBE32(&in); + } + PsdSkip(&in, 4); /* "8BIM" */ + { + const unsigned char *key = + PsdTake(&in, 4); + + if (key == NULL) { + in.bad = 1; + break; + } + rec[i].mode2 = PsdBlendMode(key); + } + rec[i].opacity = ((int) PsdRByte(&in) * 100 + 127) / 255; + PsdRByte(&in); /* clipping */ + rec[i].hidden = (int) PsdRByte(&in) & 2; + PsdRByte(&in); /* filler */ + { + unsigned long exLen = PsdRBE32(&in); + size_t exBase = in.at; + size_t exEnd = exBase + exLen; + unsigned long maskLen, rangeLen; + int nl; + + if (in.bad || exEnd > liEnd) { + in.bad = 1; + break; + } + maskLen = PsdRBE32(&in); + PsdSkip(&in, maskLen); + rangeLen = PsdRBE32(&in); + PsdSkip(&in, rangeLen); + nl = (int) PsdRByte(&in); + for (k = 0; k < nl && + k < (int) sizeof rec[i].name - 1; k++) + rec[i].name[k] = + (char) PsdRByte(&in); + rec[i].name[k] = '\0'; + in.at = exEnd; + } + } + if (!in.bad) { + dataAt = in.at; + /* the stack the layers land in */ + LayerInvalidate(); + for (i = 0; i < nrec; i++) { + Layer *L = &layers[i]; + int rw = rec[i].r - rec[i].l; + int rh = rec[i].b - rec[i].t; + int hasAlpha = 0, k; + + if (rw <= 0 || rh <= 0 || + rw > w || rh > h) { + bad = 1; + break; + } + L->rgb = calloc((size_t) w * h, 3); + if (L->rgb == NULL) { + bad = 1; + break; + } + snprintf(L->name, + sizeof L->name, "%s", + rec[i].name[0] ? rec[i].name : + (i == 0 ? "Background" : "Layer")); + L->visible = rec[i].hidden ? 0 : 1; + L->opacity = rec[i].opacity; + L->mode = rec[i].mode2; + L->cover = NULL; + for (k = 0; k < rec[i].nch; k++) + if (rec[i].cid[k] == -1) + hasAlpha = 1; + if (hasAlpha) { + L->cover = malloc( + (size_t) w * h); + if (L->cover == NULL) { + bad = 1; + break; + } + /* a pixel outside the + * rectangle is not + * painted, so it does + * not cover */ + memset(L->cover, 0, + (size_t) w * h); + } + in.at = dataAt; + for (k = 0; k < rec[i].nch; k++) { + unsigned char *plane; + size_t at0 = in.at; + size_t end = at0 + + rec[i].clen[k]; + int comp; + + if (rec[i].clen[k] < 2 || + end > liEnd) { + bad = 1; + break; + } + comp = (int) PsdRBE16(&in); + plane = malloc( + (size_t) rw * rh); + if (plane == NULL || + PsdReadPlane(&in, plane, + rw, rh, comp, end) != 0) { + free(plane); + fprintf(stderr, + "dtphoto: layer %d " + "channel %d: compression %d " + "not readable\n", + i, rec[i].cid[k], comp); + bad = 1; + break; + } + for (y = 0; y < rh; y++) + for (x = 0; x < rw; x++) { + size_t di = (size_t) + (rec[i].t + y) * w + + (rec[i].l + x); + unsigned char v = + plane[(size_t) y * rw + x]; + + if (rec[i].cid[k] == -1) { + if (L->cover != NULL) + L->cover[di] = v; + } else if (rec[i].cid[k] < 3) + L->rgb[di * 3 + + rec[i].cid[k]] = v; + } + free(plane); + /* the next channel starts where + * this one ended: packbits is not + * the same length as raw */ + dataAt = in.at; + (void) at0; + if (in.bad) { + bad = 1; + break; + } + } + if (bad) + break; + } + if (!bad) { + nlayers = nrec; + layerW = w; + layerH = h; + curLayer = 0; + haveLayers = 1; + } else + LayerInvalidate(); + } + } + } + + /* the merged image starts after the whole section: the + * global layer mask info sits between records and image */ + in.at = lmEnd; + in.bad = 0; + } + + if (!haveLayers) { + /* a flat file: the merged image is the picture */ + unsigned char *merged, *plane; + int comp; + + comp = (int) PsdRBE16(&in); + merged = malloc((size_t) w * h * 3); + plane = malloc((size_t) w * h); + if (merged == NULL || plane == NULL || in.bad) { + fprintf(stderr, "dtphoto: %s holds no readable picture\n", + path); + free(merged); + free(plane); + free(buf); + return -1; + } + for (ch = 0; ch < 3 && !in.bad; ch++) { + if (PsdReadPlane(&in, plane, w, h, comp, size) != 0) { + in.bad = 1; + break; + } + for (y = 0; y < h; y++) + for (x = 0; x < w; x++) + merged[((size_t) y * w + x) * 3 + ch] = + plane[(size_t) y * w + x]; + } + free(plane); + if (in.bad) { + fprintf(stderr, "dtphoto: %s: the merged image is " + "compressed with %d, which this reader does not take\n", + path, comp); + free(merged); + free(buf); + return -1; + } + LayerInvalidate(); + layers[0].rgb = merged; + layers[0].cover = NULL; + snprintf(layers[0].name, sizeof layers[0].name, "Background"); + layers[0].visible = 1; + layers[0].opacity = layerOpacityDefault; + layers[0].mode = 0; + nlayers = 1; + layerW = w; + layerH = h; + curLayer = 0; + } + free(buf); + + LayerSync(); + return 0; +} + +/* + * Write the document as a PSD, layers and all. Every rectangle is the whole + * canvas because dtphoto's stack is document-sized, so a layer carries no + * offset; raw planes, which is what 2.5 wrote before RLE was worth it and + * what every reader since takes. + */ +static int +SavePSD(const char *path) +{ + PSDOut o; + FILE *f; + unsigned char *composite, *plane; + int w, h, i, ch, y, x, ok; + size_t lmLen, liLen; + size_t (*chanSize)[4]; + + LayerEnsure(); + if (nlayers == 0 || layerW <= 0 || layerH <= 0) + return -1; + w = layerW; + h = layerH; + memset(&o, 0, sizeof o); + if (LayerComposite(&composite) != 0) + return -1; + if ((plane = malloc((size_t) w * h)) == NULL) { + free(composite); + return -1; + } + + PsdPut(&o, "8BPS", 4); + PsdBE16(&o, 1); /* version */ + PsdPut(&o, "\0\0\0\0\0\0", 6); /* reserved */ + PsdBE16(&o, 3); /* channels */ + PsdBE32(&o, (unsigned long) h); + PsdBE32(&o, (unsigned long) w); + PsdBE16(&o, 8); /* bits per channel */ + PsdBE16(&o, 3); /* colour mode: RGB */ + PsdBE32(&o, 0); /* colour mode data */ + PsdBE32(&o, 0); /* image resources */ + + lmLen = PsdMark(&o); /* layer and mask information */ + liLen = PsdMark(&o); /* layer info */ + + /* + * The format puts every layer record before any channel data, so + * the length of each channel has to be known before it is written. + * PackBits makes that length depend on the pixels, so it is measured + * here, with the same routine that will do the writing. + */ + if ((chanSize = malloc(sizeof *chanSize * (size_t) nlayers)) == NULL) { + free(plane); + free(composite); + return -1; + } + for (i = 0; i < nlayers; i++) { + int nch = 3 + (layers[i].cover != NULL ? 1 : 0); + + for (ch = 0; ch < nch; ch++) { + for (y = 0; y < h; y++) + for (x = 0; x < w; x++) + plane[(size_t) y * w + x] = ch < 3 ? + layers[i].rgb[((size_t) y * w + x) * 3 + ch] : + (layers[i].cover != NULL ? + layers[i].cover[(size_t) y * w + x] : 0); + chanSize[i][ch] = PsdPlaneSize(plane, w, h); + } + } + + PsdBE16(&o, (unsigned) nlayers); + for (i = 0; i < nlayers; i++) { + int nch = 3 + (layers[i].cover != NULL ? 1 : 0); + + PsdBE32(&o, 0); /* top */ + PsdBE32(&o, 0); /* left */ + PsdBE32(&o, (unsigned long) h); /* bottom */ + PsdBE32(&o, (unsigned long) w); /* right */ + PsdBE16(&o, (unsigned) nch); + for (ch = 0; ch < nch; ch++) { + /* -1 is transparency; 0/1/2 red/green/blue */ + PsdBE16(&o, (unsigned) (ch == 3 ? 0xffff : ch)); + PsdBE32(&o, (unsigned long) chanSize[i][ch]); + } + PsdPut(&o, "8BIM", 4); + PsdPut(&o, PsdBlendKey(layers[i].mode), 4); + /* the file keeps opacity in 255ths, the stack in percent */ + PsdByte(&o, (unsigned) ((layers[i].opacity * 255 + 50) / 100)); + PsdByte(&o, 0); /* clipping: base */ + PsdByte(&o, (unsigned) (layers[i].visible ? 0 : 2)); + PsdByte(&o, 0); /* filler */ + { + size_t exLen = PsdMark(&o); + size_t exBase = o.len; + + PsdBE32(&o, 0); /* no layer mask */ + PsdBE32(&o, 0); /* no blending ranges */ + PsdPascal(&o, layers[i].name, exBase); + PsdFix(&o, exLen); + } + } + + /* the channel data of every layer, one plane at a time */ + for (i = 0; i < nlayers; i++) { + int nch = 3 + (layers[i].cover != NULL ? 1 : 0); + + for (ch = 0; ch < nch; ch++) { + unsigned char *full; + + /* + * PsdWritePlane needs the whole plane, not a row at a + * time, because it compares the packed size with the + * raw one before it writes anything. + */ + if ((full = malloc((size_t) w * h)) == NULL) { + free(plane); + free(composite); + free(o.p); + return -1; + } + for (y = 0; y < h; y++) + for (x = 0; x < w; x++) + full[(size_t) y * w + x] = ch < 3 ? + layers[i].rgb[((size_t) y * w + x) * 3 + ch] : + (layers[i].cover != NULL ? + layers[i].cover[(size_t) y * w + x] : 0); + PsdWritePlane(&o, full, w, h); + free(full); + } + } + PsdFix(&o, liLen); /* records + channel data */ + PsdBE32(&o, 0); /* global layer mask info: empty */ + PsdFix(&o, lmLen); + + /* the merged image, so a reader without layers sees the picture */ + for (ch = 0; ch < 3; ch++) { + for (y = 0; y < h; y++) + for (x = 0; x < w; x++) + plane[(size_t) y * w + x] = + composite[((size_t) y * w + x) * 3 + ch]; + PsdWritePlane(&o, plane, w, h); + } + + free(plane); + free(composite); + free(chanSize); + if (o.fail) { + free(o.p); + return -1; + } + if ((f = fopen(path, "wb")) == NULL) { + free(o.p); + return -1; + } + ok = fwrite(o.p, 1, o.len, f) == o.len ? 0 : -1; + if (fclose(f) != 0) + ok = -1; + free(o.p); + return ok; +} + +/* ------------------------------------------------------------------- tiff */ + +/* + * TIFF, baseline, as Photoshop 3 writes it: little-endian, RGB or a + * palette, one strip, no compression on the way out and PackBits accepted + * on the way in. The reader is deliberately not libtiff: dtphoto carries + * its own decoders (BMP, PSD, ICO) and a picture format that needs a + * second library only for reading is not a small reader. + * + * Everything here is in the file's own byte order, so the accessors take + * whether the header said "II" or "MM". + */ +typedef struct { + unsigned char *p; + size_t len, cap; + int fail; +} TiffOut; + +static void +TiffPut(TiffOut *o, const void *d, size_t n) +{ + if (o->fail) + return; + if (o->len + n > o->cap) { + size_t cap = o->cap ? o->cap : 4096; + unsigned char *np; + + while (cap < o->len + n) + cap *= 2; + if ((np = realloc(o->p, cap)) == NULL) { + o->fail = 1; + return; + } + o->p = np; + o->cap = cap; + } + memcpy(o->p + o->len, d, n); + o->len += n; +} + +/* a 16-bit value in the output's order (the writer is always little) */ +static void +TiffS16(TiffOut *o, unsigned v) +{ + unsigned char b[2]; + + b[0] = (unsigned char) (v & 0xff); + b[1] = (unsigned char) ((v >> 8) & 0xff); + TiffPut(o, b, 2); +} + +static void +TiffS32(TiffOut *o, unsigned long v) +{ + unsigned char b[4]; + + PutLE(b, v, 4); + TiffPut(o, b, 4); +} + +static int +TiffRead16(FILE *f, int big) +{ + int a = fgetc(f), b = fgetc(f); + + if (a == EOF || b == EOF) + return -1; + return big ? (a << 8) | b : (b << 8) | a; +} + +static long +TiffRead32(FILE *f, int big) +{ + int a = fgetc(f), b = fgetc(f), c = fgetc(f), d = fgetc(f); + + if (a == EOF || b == EOF || c == EOF || d == EOF) + return -1; + if (big) + return ((long) a << 24) | ((long) b << 16) | + ((long) c << 8) | (long) d; + return ((long) d << 24) | ((long) c << 16) | + ((long) b << 8) | (long) a; +} + +/* one entry of the image file directory */ +typedef struct { + int tag; + int type; + long count; + unsigned char raw[4]; /* the value field, verbatim */ + long value; /* raw[] as a number, little-endian */ +} TiffEntry; + +/* + * How many bytes one element of a tag occupies. A tag whose whole array + * fits in the four value bytes holds it there; anything larger is an + * offset into the file. Getting this wrong turns a two-value + * BitsPerSample into a file offset, which is how a 16-bit LZW TIFF read + * as garbage. + */ +static int +TiffTypeSize(int type) +{ + switch (type) { + case 1: case 2: case 6: case 7: + return 1; + case 3: case 8: + return 2; + case 4: case 9: case 11: case 13: + return 4; + case 5: case 10: case 12: + return 8; + default: + return 0; + } +} + +/* one element of an inline array, in the file's byte order */ +static long +TiffInlineLong(const unsigned char *raw, int type, long i, int big) +{ + int esz = TiffTypeSize(type); + long v = 0; + int k; + + if (esz <= 0) + return -1; + if (esz == 1) + return raw[i]; + if (esz == 2) { + int a = raw[i * 2], b = raw[i * 2 + 1]; + + return big ? (a << 8) | b : (b << 8) | a; + } + if (big) + for (k = 0; k < 4; k++) + v = (v << 8) | raw[i * 4 + k]; + else + for (k = 3; k >= 0; k--) + v = (v << 8) | raw[i * 4 + k]; + return v; +} + +static long TiffLzw(const unsigned char *in, size_t n, + unsigned char *out, size_t want); + +/* + * The reader. It takes 8-bit RGB (photometric 2), a palette + * (photometric 3) and greyscale (0/1); colour by strip, uncompressed or + * PackBits. Anything else is refused with a message instead of a guess. + */ +static int +OpenTIFF(const char *path) +{ + FILE *f; + int big, order_a, order_b, i, nent, photometric = -1, bps = 8; + int spp = 3, compression = 1, rowsPerStrip = -1, planar = 1; + long bpsOff = -1, bpsCount = 0; + unsigned char bpsRaw[4] = { 0, 0, 0, 0 }; + int sampBytes = 1; + long w = -1, h = -1, stripOff = -1, stripLen = -1, count = -1; + long paletteOff = -1, paletteLen = 0, ifd; + unsigned char *rgb = NULL, *pal = NULL, *raw = NULL, *data = NULL; + TiffEntry *ent = NULL; + int ret = -1; + + if ((f = fopen(path, "rb")) == NULL) + return -1; + order_a = fgetc(f); + order_b = fgetc(f); + if (order_a == EOF || order_b == EOF) { + fclose(f); + return -1; + } + if (order_a == 'I' && order_b == 'I') + big = 0; + else if (order_a == 'M' && order_b == 'M') + big = 1; + else { + fclose(f); + return -1; /* not a TIFF at all */ + } + if (TiffRead16(f, big) != 42) { + fclose(f); + return -1; + } + if ((ifd = TiffRead32(f, big)) < 0) { + fclose(f); + return -1; + } + if (fseek(f, ifd, SEEK_SET) != 0) { + fclose(f); + return -1; + } + nent = TiffRead16(f, big); + if (nent < 0 || nent > 4096) { + fclose(f); + return -1; + } + if ((ent = calloc((size_t) nent, sizeof *ent)) == NULL) { + fclose(f); + return -1; + } + for (i = 0; i < nent; i++) { + int tag = TiffRead16(f, big); + int type = TiffRead16(f, big); + long cnt = TiffRead32(f, big); + int k; + long v; + + if (tag < 0 || type < 0 || cnt < 0) + goto out; + ent[i].tag = tag; + ent[i].type = type; + ent[i].count = cnt; + for (k = 0; k < 4; k++) { + int c = fgetc(f); + + if (c == EOF) + goto out; + ent[i].raw[k] = (unsigned char) c; + } + ent[i].value = TiffInlineLong(ent[i].raw, 4, 0, big); + if (ent[i].value < 0) + goto out; + /* an element of the first value, when it is inline */ + v = cnt > 0 && TiffTypeSize(type) > 0 && + cnt * TiffTypeSize(type) <= 4 ? + TiffInlineLong(ent[i].raw, type, 0, big) : ent[i].value; + switch (tag) { + case 256: w = v; break; /* ImageWidth */ + case 257: h = v; break; /* ImageLength */ + case 258: /* BitsPerSample */ + /* + * An array: one or two values sit in the tag + * itself, more are an offset and are read below. + */ + bps = cnt == 1 ? (int) v : -1; + bpsOff = v; + bpsCount = cnt; + memcpy(bpsRaw, ent[i].raw, 4); + break; + case 259: compression = (int) v; break; + case 262: photometric = (int) v; break; + case 273: stripOff = v; break; /* StripOffsets */ + case 277: spp = (int) v; break; + case 278: rowsPerStrip = (int) v; break; + case 279: stripLen = v; break; /* StripByteCounts */ + case 284: planar = (int) v; break; /* PlanarConfig */ + case 320: /* ColorMap */ + paletteOff = v; + paletteLen = cnt; + break; + default: + break; + } + } + if (w <= 0 || h <= 0 || w > 65000 || h > 65000) + goto out; + if (bpsCount > 1) { + /* + * Every sample shares one depth, so all the entries must + * agree. Two or fewer 16-bit values fit in the tag's own + * four bytes; more are stored after it and need a seek. + */ + long k; + int inline3 = bpsCount * 2 <= 4; + + if (bpsOff < 0) + goto out; + if (!inline3 && fseek(f, bpsOff, SEEK_SET) != 0) + goto out; + for (k = 0; k < bpsCount; k++) { + int v2; + + if (inline3) + v2 = (int) TiffInlineLong(bpsRaw, 3, k, big); + else + v2 = TiffRead16(f, big); + if (v2 < 0) + goto out; + if (k == 0) + bps = v2; + else if (v2 != bps) + goto out; /* mixed depths */ + } + } + if (planar != 1) + goto out; + sampBytes = bps == 16 ? 2 : 1; + /* 8 and 16 bit samples, and 1/4-bit for an indexed picture: the + * map decides the depth there, not the samples */ + if (!(bps == 8 || bps == 16 || (bps == 4 && photometric == 3))) + goto out; + if (stripOff < 0 || stripLen <= 0) + goto out; + if (photometric < 0) + photometric = spp >= 3 ? 2 : 1; + /* + * SamplesPerPixel is optional, and a grayscale photometric says it + * itself: one sample per pixel, whatever tag 277 claims or omits. + * Keeping the default of 3 makes a 16-bit gray LZW strip look + * three times too long and the file unreadable. + */ + if (photometric == 0 || photometric == 1) + spp = 1; + if (rowsPerStrip <= 0) + rowsPerStrip = (int) h; + + /* the palette is three arrays of 16-bit values, R then G then B */ + if (photometric == 3) { + long n = paletteLen > 0 ? paletteLen : 3L * 256; + int c; + + if ((pal = malloc((size_t) n)) == NULL) + goto out; + if (fseek(f, paletteOff, SEEK_SET) != 0) + goto out; + for (c = 0; c < n; c++) { + int v2 = TiffRead16(f, big); + + if (v2 < 0) + goto out; + /* + * A ColorMap is 16-bit per entry even for an 8-bit + * picture; the high byte is the colour, so 0xffff + * is white and not 255/256 of it. + */ + pal[c] = (unsigned char) (v2 >> 8); + } + } + + if ((raw = malloc((size_t) stripLen)) == NULL) + goto out; + if (fseek(f, stripOff, SEEK_SET) != 0) + goto out; + if (fread(raw, 1, (size_t) stripLen, f) != (size_t) stripLen) + goto out; + + if ((data = malloc((size_t) w * h * spp * + (size_t) sampBytes)) == NULL) + goto out; + if (compression == 1) { + size_t need = (size_t) w * h * spp * + (size_t) sampBytes; + + if ((size_t) stripLen < need) + need = (size_t) stripLen; + memcpy(data, raw, need); + count = (long) need; + } else if (compression == 32773) { + /* PackBits: a signed byte n either repeats the next byte + * (0..127: n+1 times) or copies -n literals (1..127). + * 128 is a no-op. It runs over the whole strip. */ + size_t src = 0, dst = 0; + size_t want = (size_t) w * h * spp * (size_t) sampBytes; + + while (src < (size_t) stripLen && dst < want) { + int n = (signed char) raw[src++]; + size_t k; + + /* + * PackBits, the way the spec defines it: 0..127 is a + * literal run of n+1 bytes, -127..-1 repeats the + * next byte 1-n times, -128 is a no-op. Getting + * these two the wrong way round still produces the + * right length and the wrong picture. + */ + if (n >= 0) { + for (k = 0; k <= (size_t) n && + dst < want; k++) + if (src < (size_t) stripLen) + data[dst++] = raw[src++]; + } else if (n != -128) { + if (src >= (size_t) stripLen) + break; + for (k = 0; k < (size_t) (1 - n) && + dst < want; k++) + data[dst++] = raw[src]; + src++; + } + } + count = (long) dst; + } else if (compression == 5) { + long made; + + made = TiffLzw(raw, (size_t) stripLen, data, + (size_t) w * h * sampBytes * + (size_t) (photometric == 3 ? 1 : spp)); + if (made < 0) { + fprintf(stderr, "dtphoto: %s: TIFF LZW stream is " + "not valid\n", path); + goto out; + } + count = made; + } else { + fprintf(stderr, "dtphoto: %s: TIFF compression %d is not " + "read here\n", path, compression); + goto out; + } + { + /* a 4-bit index packs two pixels into one byte, so the + * strip is half as long as the pixel count suggests */ + size_t need = (size_t) w * h * + (size_t) (photometric == 3 ? 1 : spp) * + (size_t) sampBytes; + + if (photometric == 3 && bps == 4) + need = ((size_t) w * h + 1) / 2; + if ((size_t) count < need) { + fprintf(stderr, "dtphoto: %s: TIFF strip is short " + "(%ld of %lu)\n", path, count, + (unsigned long) need); + goto out; + } + } + + if (getenv("DTPHOTO_TIFF_DEBUG") != NULL) { + int k; + + fprintf(stderr, "dtphoto: tiff %s %ldx%ld bps=%d spp=%d " + "photo=%d comp=%d bytes=%d strip=%ld data=", path, w, h, + bps, spp, photometric, compression, sampBytes, count); + for (k = 0; k < 12 && k < count; k++) + fprintf(stderr, "%02x", data[k]); + fprintf(stderr, "\n"); + } + if ((rgb = malloc((size_t) w * h * 3)) == NULL) + goto out; + { + long x, y; + + for (y = 0; y < h; y++) { + for (x = 0; x < w; x++) { + size_t idx = (size_t) y * w + x; + size_t src = idx * + (size_t) (photometric == 3 ? 1 : spp) * + (size_t) sampBytes; + size_t d = idx * 3; + unsigned char *o = rgb + d; + + if (photometric == 3) { + int ci; + + if (bps == 4) { + /* two pixels per byte, the + * high nibble first */ + unsigned char b = + data[idx / 2]; + + ci = (idx & 1) ? (b & 0x0f) : + (b >> 4); + } else if (bps == 16) { + int v2 = big ? + (data[src] << 8) | + data[src + 1] : + (data[src + 1] << 8) | + data[src]; + + ci = v2 & 0xff; + } else + ci = data[src]; + + if (pal != NULL && paletteLen >= 3) { + long n = paletteLen / 3; + + o[0] = pal[ci]; + o[1] = pal[(size_t) n + ci]; + o[2] = pal[(size_t) 2 * + n + ci]; + } else { + o[0] = o[1] = o[2] = + (unsigned char) ci; + } + } else if (bps == 16) { + /* the high byte is the 8-bit + * picture: 65535 and 255 are both + * "white", so dropping the low + * byte is a division, not a + * rounding that shifts a mid grey */ + int k; + + for (k = 0; k < 3; k++) { + size_t q = src + + (size_t) (spp >= 3 ? k : 0) * + 2; + int v2 = big ? + (data[q] << 8) | data[q + 1] : + (data[q + 1] << 8) | data[q]; + + /* 16 bit down to 8: divide, + * so 0xffff is 255 and 0x8080 + * is 128. Dropping the low + * byte would be 127. */ + o[k] = (unsigned char) + ((v2 * 255 + 32767) / 65535); + } + } else if (spp >= 3) { + o[0] = data[src]; + o[1] = data[src + 1]; + o[2] = data[src + 2]; + } else { + o[0] = o[1] = o[2] = data[src]; + } + } + } + } + if (SetImageRGB(rgb, (int) w, (int) h) != 0) + goto out; + ret = 0; +out: + free(ent); + free(pal); + free(raw); + free(data); + free(rgb); + fclose(f); + return ret; +} + +/* + * The writer: baseline, little-endian, RGB, one strip, no compression. + * A TIFF tag is a 12-byte entry, so the directory is assembled from a + * table instead of one TiffS16/TiffS32 pair per tag: the count and the + * offsets stay in step that way. + */ +typedef struct { + unsigned tag; + unsigned type; /* 3 = SHORT, 4 = LONG, 5 = RATIONAL */ + unsigned count; + unsigned long value; /* a number, or an offset once known */ + int isOffset; /* the value is a file offset, patch it */ +} TiffTag; + +/* + * TIFF's LZW: variable-width codes, MSB first, 9 to 12 bits, 256 is + * Clear and 257 EndOfInformation. A code table entry is a prefix code + * plus one byte, which is all a decode needs to be fast and exact. + * + * This is deliberately its own decompressor. The format is small, and a + * picture editor that cannot read an LZW TIFF cannot read the TIFF files + * a person actually has. + */ +typedef struct { + int prefix; /* -1 for a single byte */ + unsigned char suffix; +} LzwEnt; + +/* the next `bits` bits, most significant first; -1 when the input ends */ +static long +LzwBits(const unsigned char *in, size_t n, size_t *pos, int bits) +{ + long v = 0; + int i; + + if (*pos + (size_t) bits > n * 8) + return -1; + for (i = 0; i < bits; i++) { + size_t bit = *pos + (size_t) i; + + v = (v << 1) | + ((in[bit >> 3] >> (7 - (bit & 7))) & 1); + } + *pos += (size_t) bits; + return v; +} + +/* + * Decode into `out`, which holds `want` bytes. Returns how many bytes + * were produced, or -1 when the stream is not valid LZW. Runs that end + * early are not an error: a strip that fills the picture is what counts. + */ +static long +TiffLzw(const unsigned char *in, size_t n, unsigned char *out, size_t want) +{ + LzwEnt *tab; + int width = 9, next = 258, prev = -1; + size_t pos = 0, made = 0; + unsigned char stack[4096]; + long rc = -1; + + if ((tab = malloc(4096 * sizeof *tab)) == NULL) + return -1; + { + int i; + + for (i = 0; i < 256; i++) { + tab[i].prefix = -1; + tab[i].suffix = (unsigned char) i; + } + for (i = 258; i < 4096; i++) { + tab[i].prefix = -1; + tab[i].suffix = 0; + } + } + + for (;;) { + long code = LzwBits(in, n, &pos, width); + int sp = 0, cur; + + if (code < 0) + break; + if (code == 256) { /* Clear */ + width = 9; + next = 258; + prev = -1; + continue; + } + if (code == 257) { /* EndOfInformation */ + break; + } + if (code > next || (code == next && prev < 0)) + goto out; /* not a code we have */ + /* + * The one code the table does not hold yet: it is the + * previous string plus its own first byte. That extra + * byte is what a decoder that forgets it loses -- one byte + * per occurrence, and everything after it shifts. + */ + { + int kwkwk = (int) code == next; + unsigned char first = 0; + + cur = kwkwk ? prev : (int) code; + while (cur >= 0) { + if (sp >= (int) sizeof stack) + goto out; + stack[sp++] = tab[cur].suffix; + cur = tab[cur].prefix; + } + if (sp > 0) + first = stack[sp - 1]; + while (sp > 0) { + unsigned char b = stack[--sp]; + + if (made < want) + out[made++] = b; + } + if (kwkwk && made < want) + out[made++] = first; + if (prev >= 0 && next < 4096) { + tab[next].prefix = prev; + tab[next].suffix = first; + next++; + } + } + prev = (int) code; + /* + * TIFF's LZW switches widths one code early: the encoder + * writes 10 bits from the moment the table has 511 entries, + * not 512, because the decoder is always one entry behind. + */ + if (next + 1 >= 512 && width == 9) + width = 10; + else if (next + 1 >= 1024 && width == 10) + width = 11; + else if (next + 1 >= 2048 && width == 11) + width = 12; + } + rc = (long) made; +out: + free(tab); + return rc; +} + +static int +SaveTIFF(const char *path) +{ + unsigned char *rgb = NULL, *pix = NULL; + TiffOut o; + FILE *f; + int w, h, y, i, ntag, ret = -1; + long dataOff, ifdOff, nextOff; + size_t pixLen, ifdPos; + TiffTag tag[16]; + + memset(&o, 0, sizeof o); + if (GetImageRGB(&rgb, &w, &h) != 0) + return -1; + pixLen = (size_t) w * h * 3; + if ((pix = malloc(pixLen)) == NULL) + goto out; + /* the buffer is RGBRGB, which is exactly the baseline layout */ + for (y = 0; y < h; y++) + memcpy(pix + (size_t) y * w * 3, rgb + (size_t) y * w * 3, + (size_t) w * 3); + + TiffPut(&o, "II", 2); + TiffS16(&o, 42); + TiffS32(&o, 0); /* patched: the IFD offset */ + dataOff = (long) o.len; + TiffPut(&o, pix, pixLen); + if (o.fail) + goto out; + + ifdOff = (long) o.len; + + ntag = 0; + tag[ntag].tag = 256; tag[ntag].type = 4; tag[ntag].count = 1; + tag[ntag].value = (unsigned long) w; tag[ntag].isOffset = 0; ntag++; + tag[ntag].tag = 257; tag[ntag].type = 4; tag[ntag].count = 1; + tag[ntag].value = (unsigned long) h; tag[ntag].isOffset = 0; ntag++; + tag[ntag].tag = 258; tag[ntag].type = 3; tag[ntag].count = 3; + tag[ntag].value = 0; tag[ntag].isOffset = 1; ntag++; /* 8,8,8 */ + tag[ntag].tag = 259; tag[ntag].type = 3; tag[ntag].count = 1; + tag[ntag].value = 1; tag[ntag].isOffset = 0; ntag++; /* none */ + tag[ntag].tag = 262; tag[ntag].type = 3; tag[ntag].count = 1; + tag[ntag].value = 2; tag[ntag].isOffset = 0; ntag++; /* RGB */ + tag[ntag].tag = 273; tag[ntag].type = 4; tag[ntag].count = 1; + tag[ntag].value = (unsigned long) dataOff; tag[ntag].isOffset = 0; + ntag++; + tag[ntag].tag = 277; tag[ntag].type = 3; tag[ntag].count = 1; + tag[ntag].value = 3; tag[ntag].isOffset = 0; ntag++; /* samples */ + tag[ntag].tag = 278; tag[ntag].type = 4; tag[ntag].count = 1; + tag[ntag].value = (unsigned long) h; tag[ntag].isOffset = 0; + ntag++; /* one strip */ + tag[ntag].tag = 279; tag[ntag].type = 4; tag[ntag].count = 1; + tag[ntag].value = (unsigned long) pixLen; tag[ntag].isOffset = 0; + ntag++; + tag[ntag].tag = 282; tag[ntag].type = 5; tag[ntag].count = 1; + tag[ntag].value = 0; tag[ntag].isOffset = 1; ntag++; /* XResolution */ + tag[ntag].tag = 283; tag[ntag].type = 5; tag[ntag].count = 1; + tag[ntag].value = 0; tag[ntag].isOffset = 1; ntag++; /* YResolution */ + tag[ntag].tag = 284; tag[ntag].type = 3; tag[ntag].count = 1; + tag[ntag].value = 1; tag[ntag].isOffset = 0; ntag++; /* chunky */ + tag[ntag].tag = 296; tag[ntag].type = 3; tag[ntag].count = 1; + tag[ntag].value = 2; tag[ntag].isOffset = 0; ntag++; /* inches */ + + /* + * Out-of-line values follow the directory, in tag order. The size + * per tag comes from its type: a SHORT is two bytes, a RATIONAL + * eight. Reserving the widest case for every tag leaves holes and + * a file whose last tag points past its end. + */ + nextOff = ifdOff + 2 + (long) ntag * 12 + 4; + for (i = 0; i < ntag; i++) + if (tag[i].isOffset) { + long esz = tag[i].type == 3 ? 2 : + tag[i].type == 5 ? 8 : 4; + + tag[i].value = (unsigned long) nextOff; + nextOff += tag[i].count * esz; + } + /* the IFD offset in the header was a placeholder */ + PutLE(o.p + 4, (unsigned long) ifdOff, 4); + + TiffS16(&o, (unsigned) ntag); + for (i = 0; i < ntag; i++) { + ifdPos = o.len; + TiffS16(&o, tag[i].tag); + TiffS16(&o, tag[i].type); + TiffS32(&o, tag[i].count); + if (tag[i].type == 3 && tag[i].count == 1) + TiffS16(&o, (unsigned) tag[i].value); + else + TiffS32(&o, tag[i].value); + /* keep the entry exactly 12 bytes */ + while (o.len < ifdPos + 12) + TiffPut(&o, "\0", 1); + } + TiffS32(&o, 0); /* no next directory */ + + /* now the values the entries point at */ + for (i = 0; i < ntag; i++) { + if (!tag[i].isOffset) + continue; + if (tag[i].tag == 258) { /* BitsPerSample */ + TiffS16(&o, 8); + TiffS16(&o, 8); + TiffS16(&o, 8); + } else if (tag[i].tag == 282 || + tag[i].tag == 283) { /* Resolution */ + TiffS32(&o, 72); + TiffS32(&o, 1); /* 72 dpi */ + } + } + if (o.fail) + goto out; + + if ((f = fopen(path, "wb")) == NULL) + goto out; + ret = fwrite(o.p, 1, o.len, f) == o.len ? 0 : -1; + if (fclose(f) != 0) + ret = -1; +out: + free(rgb); + free(pix); + free(o.p); + return ret; +} + static int OpenImage(const char *path) { McdeThumbImage image; int i; + /* PSD carries layers, so it is read by the reader below and not + * by the flat-image decoder */ + if (PsdEndsWith(path, ".psd") && OpenPSD(path) == 0) { + free(docPath); + docPath = strdup(path); + return 0; + } if (OpenBMP(path) == 0) { free(docPath); docPath = strdup(path); return 0; } + /* OpenTIFF returns 1 for "not a TIFF" so a .tif name that is really + * a bitmap still gets its chance below */ + if (OpenTIFF(path) == 0) { + free(docPath); + docPath = strdup(path); + return 0; + } memset(&image, 0, sizeof image); if (McdeThumbRead(path, 0, 0, &image) != 0) return -1; @@ -1300,9 +3068,15 @@ OpenImage(const char *path) } /* - * The document into a file. The ending decides: .png and .bmp are written - * by libDtSvc, anything else keeps the BMP writer this program has always - * had, so an old name without an ending still works. + * The document into a file. The ending decides: libDtSvc writes PNG, BMP, + * JPEG, GIF and XPM, this program writes PSD (a layer stack does not fit a + * flat pixmap), and a name with none of those endings gets BMP -- but under + * a .bmp name, never under the name it asked for. + * + * It used to fall back silently: saving "plan.tiff" wrote a Windows bitmap + * called plan.tiff. Every reader that trusts the ending then refuses the + * file, and the mistake only shows up when somebody else opens it + * (measured 2026-11-22). */ /* * File > Export: the picture through the shared writer, without becoming @@ -1316,6 +3090,10 @@ ExportImage(const char *path) unsigned char *rgb; int w, h, r; + if (PsdEndsWith(path, ".psd")) { + /* the layer stack, not the composite: that is the point */ + return SavePSD(path); + } if (GetImageRGB(&rgb, &w, &h) != 0) return -1; r = McdeThumbWrite(path, rgb, w, h); @@ -1329,17 +3107,55 @@ SaveImage(const char *path) unsigned char *rgb; int w, h, i; - if (GetImageRGB(&rgb, &w, &h) != 0) - return -1; - if (McdeThumbWrite(path, rgb, w, h) == 0 || - SaveBMP(path) == 0) { - free(rgb); + if (PsdEndsWith(path, ".psd")) { + if (SavePSD(path) != 0) + return -1; free(docPath); docPath = strdup(path); return 0; } + if (PsdEndsWith(path, ".tif") || PsdEndsWith(path, ".tiff")) { + if (SaveTIFF(path) != 0) { + fprintf(stderr, "dtphoto: %s: cannot write\n", path); + return -1; + } + free(docPath); + docPath = strdup(path); + return 0; + } + if (GetImageRGB(&rgb, &w, &h) != 0) + return -1; + /* + * The BMP writer takes any name, so asking it after a failed + * McdeThumbWrite is what produced a bitmap called plan.tiff. The + * ending is checked first: a name this build cannot write is an + * error, and a name with no ending at all is a BMP, as it always + * was. + */ + { + const char *dot = strrchr(path, '.'); + int bmpname = dot == NULL || + strcasecmp(dot, ".bmp") == 0; + + if (!bmpname && McdeThumbWrite(path, rgb, w, h) != 0) { + fprintf(stderr, + "dtphoto: %s: cannot write that ending; " + "this build saves PSD, PNG, BMP, JPEG, " + "GIF and XPM\n", + path); + free(rgb); + return -1; + } + if (bmpname && SaveBMP(path) != 0) { + fprintf(stderr, "dtphoto: %s: cannot write\n", path); + free(rgb); + return -1; + } + } free(rgb); - return -1; + free(docPath); + docPath = strdup(path); + return 0; } /* @@ -1367,6 +3183,7 @@ static const struct { { "File/Quit", CMD_QUIT }, /* Edit */ { "Edit/Undo", CMD_UNDO }, + { "Edit/Redo", CMD_REDO }, { "Edit/Cut", CMD_CUT }, { "Edit/Copy", CMD_COPY }, { "Edit/Paste", CMD_PASTE }, @@ -1785,6 +3602,299 @@ BuildMenu(Widget parent, Menu *m) /* ------------------------------------------------------------------- view */ +/* + * The undo history. Until 2026-11-22 `snap` was the whole of it: one + * frame, so one step back, while File > Preferences offered "Undo depth" + * and the value was never read. Photoshop 3 keeps several. + * + * The ring holds frames of the document size. One of them is the picture + * on screen; `undoLive` says the screen is newer than every frame (a + * change was recorded but its result has not been snapshotted yet). That + * is what makes Record cheap: it runs *before* a change, when the old + * picture is still on screen, so it only has to declare the old frame + * reachable -- the new state becomes a frame when someone steps back into + * it, and stepping forward again then returns to it exactly. + * + * A change of document size drops the lot: a frame of 1024x768 cannot be + * a state of a 768x1024 picture. + */ +#define UNDO_MAX 32 +/* + * A frame is more than pixels: a selection is part of the state a person + * wants back. Marque a strip, Clear, Undo -- before 2026-11-22 the paint + * came back and the marquee did not, because only the pixmap was kept. + * The mask travels with it, copied lazily (only while a selection exists). + */ +static Pixmap undoRing[UNDO_MAX]; +static unsigned char *undoMask[UNDO_MAX]; /* the selection, or NULL */ +static int undoPos; /* how many frames the ring holds */ +static int undoAt; /* which of them the screen shows */ +static int undoLive; /* the screen is newer than that frame */ + +static void UndoTrim(void); + +/* how many frames a document may hold: the current one plus the depth */ +static int +UndoFrames(void) +{ + int d = undoDepth < 1 ? 1 : undoDepth; + + if (d > UNDO_MAX - 1) + d = UNDO_MAX - 1; + return d + 1; +} + +/* the picture on screen becomes a frame; -1 when there is no picture */ +static int +HistoryPush(void) +{ + Pixmap p; + int i; + + if (image == None || docW < 1 || docH < 1) + return -1; + /* a new state has nothing in front of it */ + for (i = undoAt + 1; i < undoPos; i++) + if (undoRing[i] != None) { + XFreePixmap(dpy, undoRing[i]); + undoRing[i] = None; + } + undoPos = undoAt + 1; + if (undoPos >= UNDO_MAX) { + /* the ring is full: the oldest frame goes */ + if (undoRing[0] != None) + XFreePixmap(dpy, undoRing[0]); + free(undoMask[0]); + undoMask[0] = NULL; + for (i = 1; i < undoPos; i++) { + undoRing[i - 1] = undoRing[i]; + undoMask[i - 1] = undoMask[i]; + } + undoPos--; + undoAt--; + } + p = XCreatePixmap(dpy, drawable, docW, docH, + (unsigned int) visdepth); + undoRing[undoPos] = p; + if (p != None) + XCopyArea(dpy, image, p, gc, 0, 0, docW, docH, 0, 0); + /* the selection is a state of its own, so it travels with the frame */ + free(undoMask[undoPos]); + undoMask[undoPos] = NULL; + if (selMask != NULL && selMaskAny) { + size_t sz = ((size_t) docW * docH + 7) / 8; + unsigned char *m = malloc(sz); + + if (m != NULL) { + memcpy(m, selMask, sz); + undoMask[undoPos] = m; + } + } + undoAt = undoPos; + undoPos++; + undoLive = 0; + UndoTrim(); + return undoAt; +} + +/* keep the newest UndoFrames() frames, drop the oldest */ +static void +UndoTrim(void) +{ + int keep = UndoFrames(), drop, i; + + drop = undoPos - keep; + if (drop <= 0) + return; + for (i = 0; i < drop; i++) { + if (undoRing[i] != None) { + XFreePixmap(dpy, undoRing[i]); + undoRing[i] = None; + } + free(undoMask[i]); + undoMask[i] = NULL; + } + for (i = drop; i < undoPos; i++) { + undoRing[i - drop] = undoRing[i]; + undoMask[i - drop] = undoMask[i]; + } + for (i = undoPos - drop; i < undoPos; i++) { + undoRing[i] = None; + undoMask[i] = NULL; + } + undoPos -= drop; + undoAt -= drop; + if (undoAt < 0) + undoAt = 0; +} + +static void +UndoReset(void) +{ + int i; + + for (i = 0; i < undoPos; i++) { + if (undoRing[i] != None) { + XFreePixmap(dpy, undoRing[i]); + undoRing[i] = None; + } + free(undoMask[i]); + undoMask[i] = NULL; + } + undoPos = 0; + undoAt = 0; + undoLive = 0; +} + +/* + * The state before a change. Called before the picture is touched. + * + * Two cases put a frame in the ring: the first change of a document (the + * base, so one Undo after one change returns to the picture as it was), + * and any change that follows a previous one without an Undo in between + * (the result of the last change becomes a frame of its own, which is what + * makes the history several steps deep). If the screen already *is* the + * newest frame, nothing has to be copied. + */ +static void +UndoRecord(void) +{ + if (image == None || docW < 1 || docH < 1) + return; + if (undoPos == 0) + HistoryPush(); /* the base of this document */ + else if (undoLive) + HistoryPush(); /* the last change, before this one */ + /* + * Otherwise undoAt is the newest frame and the screen matches it; + * HistoryPush would drop the frames in front, which is exactly + * what happens on the next call after an Undo. + */ + undoLive = 1; /* the screen is about to move off it */ +} + +/* + * A selection on its own is a step. The tools call this before they + * change the mask, so Marque, Clear, Undo does what a person expects: + * the paint and the marquee come back together. + */ +static void +UndoRecordSelection(void) +{ + if (image == None || docW < 1 || docH < 1) + return; + if (undoPos == 0) + HistoryPush(); + else if (undoLive) + HistoryPush(); + /* the frame on screen now carries this selection */ + if (undoAt >= 0 && undoAt < undoPos) { + free(undoMask[undoAt]); + undoMask[undoAt] = NULL; + if (selMask != NULL && selMaskAny) { + size_t sz = ((size_t) docW * docH + 7) / 8; + unsigned char *m = malloc(sz); + + if (m != NULL) { + memcpy(m, selMask, sz); + undoMask[undoAt] = m; + } + } + } +} + +/* drop the history: the picture on screen is the only state left */ +static void +UndoForget(void) +{ + UndoReset(); +} + +/* how many steps back are reachable */ +static int +UndoAhead(void) +{ + return undoLive ? 1 : undoAt; +} + +/* how many steps forward are reachable */ +static int +RedoAhead(void) +{ + return undoLive ? 0 : undoPos - 1 - undoAt; +} + +/* bring one of the frames to the screen; 1 when something moved */ +static int +HistoryGo(int at) +{ + if (at < 0 || at >= undoPos || undoRing[at] == None) + return 0; + if (!undoLive && at == undoAt) + return 0; + if (undoLive && at > undoAt) + return 0; + undoAt = at; + undoLive = 0; + XCopyArea(dpy, undoRing[undoAt], image, gc, 0, 0, docW, docH, 0, 0); + XCopyArea(dpy, image, snap, gc, 0, 0, docW, docH, 0, 0); + /* the selection that belonged to those pixels */ + if (undoMask[undoAt] != NULL) { + size_t sz = ((size_t) docW * docH + 7) / 8; + + if (MaskAlloc() == 0) { + int mx, my, bx0 = docW, by0 = docH, bx1 = -1, by1 = -1; + + memcpy(selMask, undoMask[undoAt], sz); + selMaskAny = 1; + /* the marquee is the box around what is selected */ + for (my = 0; my < docH; my++) + for (mx = 0; mx < docW; mx++) + if (MaskGet(mx, my)) { + if (mx < bx0) bx0 = mx; + if (my < by0) by0 = my; + if (mx > bx1) bx1 = mx; + if (my > by1) by1 = my; + } + if (bx1 >= 0) { + selX0 = bx0; + selY0 = by0; + selX1 = bx1 + 1; + selY1 = by1 + 1; + hasSel = 1; + } + } + } else { + MaskClear(); + hasSel = 0; + } + RenderDoc(canvas); + return 1; +} + +/* + * One step back. A live screen is not a frame yet, so it becomes one + * first -- that is what Redo returns to afterwards. + */ +static int +UndoStep(void) +{ + if (undoLive) { + if (HistoryPush() < 0) + return 0; + return HistoryGo(undoAt - 1); + } + return HistoryGo(undoAt - 1); +} + +static int +RedoStep(void) +{ + if (undoLive) + return 0; + return HistoryGo(undoAt + 1); +} + static void NewPixmaps(void) { @@ -1792,6 +3902,8 @@ NewPixmaps(void) XFreePixmap(dpy, image); if (snap != None) XFreePixmap(dpy, snap); + /* a fresh document size: no state of the old one fits it */ + UndoReset(); image = XCreatePixmap(dpy, drawable, docW, docH, (unsigned int) visdepth); snap = XCreatePixmap(dpy, drawable, docW, docH, @@ -2593,6 +4705,172 @@ MaskAlloc(void) return 0; } +/* + * The selection has to follow the picture. A flip or a rotation used to + * leave the mask where it was: after Image > Flip Horizontal the selected + * pixels were the ones on the other side, so Clear wiped a part of the + * picture nobody had chosen (a rotation lost the selection altogether, + * because the new size threw the mask away). + * + * `turn` is the same one OpRotate takes (0 = 180, 1 = clockwise, + * -1 = counter-clockwise), `flip` is 0/1/2 for none/vertical/horizontal. + * Old coordinates come from the old width and height, so this has to run + * before the document size changes. + */ +static int +MaskTransform(int flip, int turn) +{ + unsigned char *nm, *nc = NULL; + size_t nsz; + int ow = docW, oh = docH; + int nw = turn == 0 ? ow : oh, nh = turn == 0 ? oh : ow; + int x, y; + + if (!selMaskAny || selMask == NULL) + return 0; + nsz = ((size_t) nw * nh + 7) / 8; + if ((nm = calloc(1, nsz)) == NULL) + return -1; + if (selCover != NULL && (nc = calloc((size_t) nw * nh, 1)) == NULL) { + free(nm); + return -1; + } + for (y = 0; y < nh; y++) + for (x = 0; x < nw; x++) { + int sx, sy; + + if (flip == 1) { + sx = x; + sy = oh - 1 - y; + } else if (flip == 2) { + sx = ow - 1 - x; + sy = y; + } else if (turn == 0) { + sx = ow - 1 - x; + sy = oh - 1 - y; + } else if (turn > 0) { + /* the same walk OpRotate does, backwards */ + sx = y; + sy = oh - 1 - x; + } else { + sx = ow - 1 - y; + sy = x; + } + if (sx < 0 || sy < 0 || sx >= ow || sy >= oh) + continue; + if ((selMask[((size_t) sy * ow + sx) >> 3] >> + ((sy * ow + sx) & 7)) & 1) { + size_t i = (size_t) y * nw + x; + + nm[i >> 3] |= (unsigned char) (1u << (i & 7)); + } + if (nc != NULL) + nc[(size_t) y * nw + x] = + selCover[(size_t) sy * ow + sx]; + } + free(selMask); + selMask = nm; + selMaskSize = nsz; + free(selCover); + selCover = nc; + selCoverSize = nc != NULL ? (size_t) nw * nh : 0; + /* the marquee rectangle has to follow too, or the marching ants lie */ + if (selX1 > selX0 && selY1 > selY0) { + int x0 = selX0, y0 = selY0, x1 = selX1, y1 = selY1; + + if (flip == 1) { + selY0 = oh - y1; + selY1 = oh - y0; + } else if (flip == 2) { + selX0 = ow - x1; + selX1 = ow - x0; + } else if (turn == 0) { + selX0 = ow - x1; + selY0 = oh - y1; + selX1 = ow - x0; + selY1 = oh - y0; + } else if (turn > 0) { + selX0 = oh - y1; + selY0 = x0; + selX1 = oh - y0; + selY1 = x1; + } else { + selX0 = y0; + selY0 = ow - x1; + selX1 = y1; + selY1 = ow - x0; + } + } + selMaskAny = 1; + hasSel = 1; + /* the buffers are already nw x nh; the caller is about to resize */ + maskSized = 1; + return 0; +} + +/* + * Canvas Size moves the picture inside a larger (or smaller) canvas, so the + * selection has to move by the same offset. Pixels outside the new canvas + * are dropped, the rest keeps its place relative to the picture -- a + * selection that stayed put would select a piece of the border instead. + */ +static int +MaskShift(int nw, int nh, int dx, int dy) +{ + unsigned char *nm, *nc = NULL; + size_t nsz; + int ow = docW, oh = docH, x, y; + + if (!selMaskAny || selMask == NULL) + return 0; + nsz = ((size_t) nw * nh + 7) / 8; + if ((nm = calloc(1, nsz)) == NULL) + return -1; + if (selCover != NULL && (nc = calloc((size_t) nw * nh, 1)) == NULL) { + free(nm); + return -1; + } + for (y = 0; y < nh; y++) + for (x = 0; x < nw; x++) { + int sx = x - dx, sy = y - dy; + + if (sx < 0 || sy < 0 || sx >= ow || sy >= oh) + continue; + if ((selMask[((size_t) sy * ow + sx) >> 3] >> + ((sy * ow + sx) & 7)) & 1) { + size_t i = (size_t) y * nw + x; + + nm[i >> 3] |= (unsigned char) (1u << (i & 7)); + } + if (nc != NULL) + nc[(size_t) y * nw + x] = + selCover[(size_t) sy * ow + sx]; + } + free(selMask); + selMask = nm; + selMaskSize = nsz; + free(selCover); + selCover = nc; + selCoverSize = nc != NULL ? (size_t) nw * nh : 0; + if (selX1 > selX0 && selY1 > selY0) { + selX0 += dx; + selX1 += dx; + selY0 += dy; + selY1 += dy; + if (selX0 < 0) selX0 = 0; + if (selY0 < 0) selY0 = 0; + if (selX1 > nw) selX1 = nw; + if (selY1 > nh) selY1 = nh; + if (selX1 <= selX0 || selY1 <= selY0) { + /* the whole selection fell outside the new canvas */ + selMaskAny = 0; + hasSel = 0; + } + } + maskSized = 1; + return 0; +} + /* * The rectangle of the marquee, into the mask. Setting the mask means * there is a selection: MaskClear() below drops hasSel, so putting the @@ -2830,6 +5108,7 @@ SelectionDistances(double **dInP, double **dOutP, int *wP, int *hP, static void SelExpand(double r) { + UndoRecordSelection(); unsigned char *sel, *out; double *dIn, *dOut; int w, h, x, y; @@ -2855,6 +5134,7 @@ SelExpand(double r) static void SelContract(double r) { + UndoRecordSelection(); unsigned char *sel, *out; double *dIn, *dOut; int w, h, x, y; @@ -2885,6 +5165,7 @@ SelContract(double r) static void SelBorder(double r) { + UndoRecordSelection(); unsigned char *sel, *out; double *dIn, *dOut; int w, h, x, y; @@ -2920,6 +5201,7 @@ SelBorder(double r) static void SelSmooth(int r) { + UndoRecordSelection(); unsigned char *sel, *out; long *sum; int w, h, x, y, side, i; @@ -3100,6 +5382,7 @@ SelColorExtend(int tolerance, int connected) static void SelFeather(int r) { + UndoRecordSelection(); unsigned char *sel; double *dIn, *dOut; int w, h, x, y; @@ -3392,7 +5675,7 @@ DrawTextAt(int x, int y, const char *s) { if (s == NULL || s[0] == '\0') return; - XCopyArea(dpy, image, snap, gc, 0, 0, docW, docH, 0, 0); + UndoRecord(); SetImageFG(); XDrawString(dpy, image, gc, x, y, s, (int) strlen(s)); RenderDoc(canvas); @@ -3542,6 +5825,7 @@ PaintMask(Pixel px) static void InvertSelection(void) { + UndoRecordSelection(); int x, y; if (MaskAlloc() != 0) @@ -4864,6 +7148,20 @@ static void PrefsOk(const int *v) { undoDepth = v[0] > 0 ? v[0] : 1; + if (undoDepth > UNDO_MAX) + undoDepth = UNDO_MAX; + /* a smaller depth must trim at once, not at the next edit */ + while (undoPos - undoAt > undoDepth) { + int i; + + XFreePixmap(dpy, undoRing[0]); + for (i = 1; i < undoPos; i++) + undoRing[i - 1] = undoRing[i]; + undoPos--; + undoAt--; + if (undoAt < 0) + undoAt = 0; + } fprintf(stderr, "dtphoto: undo depth %d\n", undoDepth); } @@ -4999,8 +7297,8 @@ static void CloseDoc(void) { XSetForeground(dpy, gc, WhitePixel(dpy, 0)); + UndoRecord(); XFillRectangle(dpy, image, gc, 0, 0, docW, docH); - XCopyArea(dpy, image, snap, gc, 0, 0, docW, docH, 0, 0); free(docPath); docPath = NULL; MaskClear(); @@ -5331,7 +7629,7 @@ PasteFromClip(int into) fprintf(stderr, "dtphoto: nothing to paste\n"); return; } - XCopyArea(dpy, image, snap, gc, 0, 0, docW, docH, 0, 0); + UndoRecord(); if (into) { if ((limit = malloc((size_t) docW * docH)) == NULL) return; @@ -6740,6 +9038,9 @@ OpFlip(int horizontal) memcpy(out + ((size_t) y * w + x) * 3, rgb + ((size_t) sy * w + sx) * 3, 3); } + /* a selection that does not move with the picture selects the wrong + * pixels afterwards */ + MaskTransform(horizontal ? 2 : 1, 0); SetImageRGB(out, w, h); free(out); free(rgb); @@ -6784,6 +9085,8 @@ OpRotate(int turn) memcpy(out + ((size_t) y * nw + x) * 3, rgb + ((size_t) sy * w + sx) * 3, 3); } + /* before the size changes: the mask is indexed by the old one */ + MaskTransform(0, turn); SetImageRGB(out, nw, nh); free(out); free(rgb); @@ -7186,6 +9489,8 @@ OpCanvasSize(int nw, int nh, int dx, int dy) memcpy(d, rgb + ((size_t) sy * w + sx) * 3, 3); } } + /* the picture moved by (dx,dy); the selection has to move with it */ + MaskShift(nw, nh, dx, dy); SetImageRGB(out, nw, nh); free(out); free(rgb); @@ -8786,7 +11091,7 @@ OpExtrude(int cell, int depth, int solidFront) { unsigned char *rgb, *out; int w, h, x, y, bx, by, c; - unsigned char br, bg, bb; + unsigned char br, bg, bb, front[3]; if (cell < 2) cell = 2; if (depth < 1) depth = 1; @@ -8797,11 +11102,15 @@ OpExtrude(int cell, int depth, int solidFront) return; } PixelToRGB(bgPixel, &br, &bg, &bb); + /* A compound literal here would put its commas between memcpy's own + * argument commas: _FORTIFY_SOURCE sees five arguments, not three. + * A named array keeps the call a three-argument call. */ + front[0] = solidFront ? br : 0; + front[1] = solidFront ? bg : 0; + front[2] = solidFront ? bb : 0; for (y = 0; y < h; y++) for (x = 0; x < w; x++) - memcpy(out + ((size_t) y * w + x) * 3, (unsigned char[]) { - solidFront ? br : 0, solidFront ? bg : 0, - solidFront ? bb : 0 }, 3); + memcpy(out + ((size_t) y * w + x) * 3, front, 3); for (by = 0; by < h; by += cell) for (bx = 0; bx < w; bx += cell) { int n = NoiseAt(bx, by, 5u); @@ -9567,6 +11876,7 @@ SelContractOk(int r, int unused) static void SelGrowRun(void) { + UndoRecordSelection(); SelColorExtend(wandTolerance, 1); RenderDoc(canvas); fprintf(stderr, "dtphoto: grow %d\n", wandTolerance); @@ -9575,6 +11885,7 @@ SelGrowRun(void) static void SelSimilarRun(void) { + UndoRecordSelection(); SelColorExtend(wandTolerance, 0); RenderDoc(canvas); fprintf(stderr, "dtphoto: similar %d\n", wandTolerance); @@ -9657,7 +11968,26 @@ CanvasInput(Widget w, XtPointer cd, XEvent *ev, Boolean *keep) /* the hand works in window pixels, not document ones */ lastScrX = x; lastScrY = y; - XCopyArea(dpy, image, snap, gc, 0, 0, docW, docH, 0, 0); + /* + * The selection tools change the mask and not the picture. + * They still have to be one step: before 2026-11-22 a marquee + * was invisible to Undo, so Clear after it could not be undone + * to "the picture with that selection". + */ + if (currentTool == 0 || currentTool == 1 || currentTool == 2 || + currentTool == 3 || currentTool == 7) { + UndoRecordSelection(); + } else if (currentTool != 5 && currentTool != 6 && + currentTool != 21) { + /* + * The tools that put paint on the picture draw + * straight into `image`, not through SetImageRGB, + * so this is the only place their state is taken. + * The hand, the magnifier and the eyedropper leave + * the picture alone and must not push a step. + */ + UndoRecord(); + } dragging = 1; switch (currentTool) { case 0: case 1: @@ -10001,6 +12331,29 @@ OptionsApply(Widget w, XtPointer cd, XtPointer call) v = (int) strtol(s, &p, 10); if (p == s) return; + /* + * A field takes any number. "5000" reached XFillArc as a radius of + * 5000 on a 320-pixel picture and "-7" drew nothing at all; the + * tolerance above 255 can never match, so it is not a tolerance. + * The limits are the ones the tools can use, not a guess. + */ + if (target == &wandTolerance) { + if (v < 0) + v = 0; + if (v > 255) + v = 255; + } else if (target == &retouchStrength) { + if (v < 0) + v = 0; + if (v > 100) + v = 100; + } else { + /* the radii: a dab of 0 draws nothing, 64 is past any brush */ + if (v < 1) + v = 1; + if (v > 64) + v = 64; + } *target = v; fprintf(stderr, "dtphoto: options %s=%d\n", (target == &pencilRadius) ? "pencil" : @@ -10251,8 +12604,8 @@ FileDialog(int save) * a PNG means typing its name: the reader knows more than the writer * did in 1993 (2026-11-22). */ - pat = XmStringCreateLocalized("*.png *.jpg *.jpeg *.gif *.bmp *.ico " - "*.xpm *"); + pat = XmStringCreateLocalized("*.psd *.png *.jpg *.jpeg *.gif *.bmp " + "*.ico *.xpm *"); XtVaSetValues(d, XmNpattern, pat, NULL); XmStringFree(pat); XtManageChild(d); @@ -10724,8 +13077,17 @@ MenuCallback(Widget w, XtPointer data, XtPointer call) case CMD_SAVEAS: FileDialog(1); break; case CMD_QUIT: exit(0); case CMD_UNDO: - XCopyArea(dpy, snap, image, gc, 0, 0, docW, docH, 0, 0); - RenderDoc(canvas); + if (!UndoStep()) + fprintf(stderr, "dtphoto: nothing to undo\n"); + else + fprintf(stderr, "dtphoto: undo, %d more\n", + UndoAhead()); + break; + case CMD_REDO: + if (!RedoStep()) + fprintf(stderr, "dtphoto: nothing to redo\n"); + else + fprintf(stderr, "dtphoto: redo\n"); break; case CMD_SHOWOPTIONS: OptionsShow(); @@ -10742,12 +13104,14 @@ MenuCallback(Widget w, XtPointer data, XtPointer call) } case CMD_ACTUAL: SetZoom(100); break; case CMD_ALL: + UndoRecordSelection(); selX0 = 0; selY0 = 0; selX1 = docW; selY1 = docH; hasSel = 1; MaskFromRect(); RenderDoc(canvas); break; case CMD_DESELECT: + UndoRecordSelection(); MaskClear(); RenderDoc(canvas); break; @@ -10781,17 +13145,17 @@ MenuCallback(Widget w, XtPointer data, XtPointer call) SelSimilarRun(); break; case CMD_CLEAR: - XCopyArea(dpy, image, snap, gc, 0, 0, docW, docH, 0, 0); + UndoRecord(); PaintMask(bgPixel); RenderDoc(canvas); break; case CMD_FILL: - XCopyArea(dpy, image, snap, gc, 0, 0, docW, docH, 0, 0); + UndoRecord(); PaintMask(fgPixel); RenderDoc(canvas); break; case CMD_CROP: - XCopyArea(dpy, image, snap, gc, 0, 0, docW, docH, 0, 0); + UndoRecord(); CropToSelection(); break; /* Image: whole-picture operations, all through one RGB buffer */ @@ -11066,7 +13430,7 @@ MenuCallback(Widget w, XtPointer data, XtPointer call) PageSetup(); break; case CMD_PREFS: - FieldDialog("Preferences", "Undo depth", "1", PrefsOk); + FieldDialog("Preferences", "Undo depth", "8", PrefsOk); break; /* Edit: the clipboard and the pattern */ case CMD_CUT: @@ -11076,7 +13440,7 @@ MenuCallback(Widget w, XtPointer data, XtPointer call) * (measured 2026-11-22). */ CopyToClip(); - XCopyArea(dpy, image, snap, gc, 0, 0, docW, docH, 0, 0); + UndoRecord(); PaintMask(bgPixel); RenderDoc(canvas); fprintf(stderr, "dtphoto: cut\n"); @@ -11234,7 +13598,7 @@ MenuCallback(Widget w, XtPointer data, XtPointer call) PublisherOptions(); break; case CMD_SNAPSHOT: - XCopyArea(dpy, image, snap, gc, 0, 0, docW, docH, 0, 0); + UndoRecord(); SetScratch("Snapshot taken: %d x %d, Edit > Undo returns " "here", docW, docH); fprintf(stderr, "dtphoto: snapshot\n"); @@ -11788,6 +14152,72 @@ main(int argc, char **argv) * the lasso and the inverse must each pick exact pixel sets. Counts, * not samples: a mask that is one pixel wrong in a corner is a bug. */ + /* + * The TIFF round trip: write a file with a split and a gradient, + * read it back and compare every byte. A format only its own + * reader understands is not a format, so the shell proof runs + * ImageMagick and PIL over the same file as well. + */ + if (argc >= 3 && strcmp(argv[1], "-tifftest") == 0) { + unsigned char *want, *back; + int w = 17, h = 11, x, y, bad = 0, bw = 0, bh = 0; + + want = malloc((size_t) w * h * 3); + if (want == NULL) { + printf("dtphoto tifftest: FAIL malloc\n"); + return 1; + } + for (y = 0; y < h; y++) + for (x = 0; x < w; x++) { + unsigned char *d = + want + ((size_t) y * w + x) * 3; + + d[0] = (unsigned char) (x * 15); + d[1] = (unsigned char) (y * 23); + d[2] = x < w / 2 ? 200 : 40; + } + if (SetImageRGB(want, w, h) != 0) { + printf("dtphoto tifftest: FAIL image\n"); + return 1; + } + if (SaveTIFF(argv[2]) != 0) { + printf("dtphoto tifftest: FAIL write\n"); + return 1; + } + if (OpenTIFF(argv[2]) != 0) { + printf("dtphoto tifftest: FAIL read\n"); + return 1; + } + if (GetImageRGB(&back, &bw, &bh) != 0) { + printf("dtphoto tifftest: FAIL readback\n"); + return 1; + } + if (bw != w || bh != h) { + printf("dtphoto tifftest: size=%dx%d want %dx%d " + "FAIL\n", bw, bh, w, h); + bad++; + } + for (y = 0; y < h && y < bh; y++) + for (x = 0; x < w && x < bw; x++) { + unsigned char *a = + back + ((size_t) y * bw + x) * 3; + unsigned char *b = + want + ((size_t) y * w + x) * 3; + + if (a[0] != b[0] || a[1] != b[1] || + a[2] != b[2]) { + printf("dtphoto tifftest: (%d,%d)=" + "%d,%d,%d want %d,%d,%d FAIL\n", + x, y, a[0], a[1], a[2], + b[0], b[1], b[2]); + bad++; + } + } + free(back); + free(want); + printf("dtphoto tifftest: %s\n", bad ? "FAIL" : "PASS"); + return bad ? 1 : 0; + } if (argc >= 2 && strcmp(argv[1], "-croptest") == 0) { unsigned char *rgb; int w = 40, h = 30, x, y, bad = 0; @@ -12511,6 +14941,352 @@ main(int argc, char **argv) * to carry out must resolve to the command the callback switches * on. A path that resolves to CMD_NONE is an entry that does * nothing but print its own label. */ + if (argc >= 2 && strcmp(argv[1], "-undotest") == 0) { + /* + * Undo, for real. A one-deep snapshot passes the first step + * and nothing after it -- that was the state before + * 2026-11-22, while File > Preferences offered a depth. The + * pixels are read out of the document, not out of a + * variable, so a history that claims depth without keeping + * the frames fails here. + * + * The states: base 100, then three changes to 60, 100, 140. + * Undo walks 100, 60, 100 and then has nothing left. + */ + unsigned char *rgb = NULL; + int w = 12, h = 8, x, y, bad = 0, step, i; + int want[4] = { 100, 60, 100, 140 }; + + rgb = malloc((size_t) w * h * 3); + if (rgb == NULL) { + printf("dtphoto undotest: FAIL malloc\n"); + return 1; + } + for (y = 0; y < h; y++) + for (x = 0; x < w; x++) { + unsigned char *d = + rgb + ((size_t) y * w + x) * 3; + + d[0] = d[1] = d[2] = 100; + } + if (SetImageRGB(rgb, w, h) != 0) { + printf("dtphoto undotest: FAIL image\n"); + free(rgb); + return 1; + } + UndoReset(); + for (step = 1; step <= 3; step++) { + int n = w * h * 3; + + if (GetImageRGB(&rgb, &w, &h) != 0) { + printf("dtphoto undotest: FAIL read\n"); + return 1; + } + /* + * No UndoRecord here: SetImageRGB records the + * state it is about to overwrite, as every caller + * of it relies on. + */ + for (i = 0; i < n; i++) + rgb[i] = (unsigned char) want[step]; + if (SetImageRGB(rgb, w, h) != 0) { + printf("dtphoto undotest: FAIL write\n"); + return 1; + } + } + free(rgb); + rgb = NULL; + if (GetImageRGB(&rgb, &w, &h) != 0) { + printf("dtphoto undotest: FAIL read final\n"); + return 1; + } + printf("dtphoto undotest: final %d want %d %s\n", rgb[0], + want[3], rgb[0] == want[3] ? "ok" : "FAIL"); + if (rgb[0] != want[3]) + bad++; + free(rgb); + printf("dtphoto undotest: %d frames kept, want %d %s\n", + undoPos, undoDepth, undoPos >= 3 ? "ok" : "FAIL"); + if (undoPos < 3) + bad++; + /* three steps back: 100, 60, 100 -- each read off the screen */ + for (step = 2; step >= 0; step--) { + rgb = NULL; + if (!UndoStep()) { + printf("dtphoto undotest: undo %d refused FAIL\n", + step + 1); + bad++; + continue; + } + if (GetImageRGB(&rgb, &w, &h) != 0) { + printf("dtphoto undotest: FAIL read back\n"); + bad++; + continue; + } + printf("dtphoto undotest: undo %d -> %d want %d %s\n", + 3 - step, rgb[0], want[step], + rgb[0] == want[step] ? "ok" : "FAIL"); + if (rgb[0] != want[step]) + bad++; + free(rgb); + } + if (UndoStep()) { + printf("dtphoto undotest: undo past the start FAIL\n"); + bad++; + } else { + printf("dtphoto undotest: undo past the start refused ok\n"); + } + /* and forward again: the redo half was kept */ + for (step = 1; step <= 3; step++) { + rgb = NULL; + if (!RedoStep()) { + printf("dtphoto undotest: redo %d refused FAIL\n", + step); + bad++; + continue; + } + if (GetImageRGB(&rgb, &w, &h) != 0) { + printf("dtphoto undotest: FAIL read fwd\n"); + bad++; + continue; + } + printf("dtphoto undotest: redo %d -> %d want %d %s\n", + step, rgb[0], want[step], + rgb[0] == want[step] ? "ok" : "FAIL"); + if (rgb[0] != want[step]) + bad++; + free(rgb); + } + /* + * A new change after an Undo must throw the redo half away: + * the frames in front were built on a picture that is gone. + */ + UndoStep(); + UndoStep(); + rgb = NULL; + if (GetImageRGB(&rgb, &w, &h) != 0) { + printf("dtphoto undotest: FAIL read branch\n"); + return 1; + } + for (i = 0; i < w * h * 3; i++) + rgb[i] = 200; + SetImageRGB(rgb, w, h); + free(rgb); + printf("dtphoto undotest: redo after a new change %d want 0 %s\n", + RedoAhead(), RedoAhead() == 0 ? "ok" : "FAIL"); + if (RedoAhead() != 0) + bad++; + printf("dtphoto undotest: %s\n", bad == 0 ? "PASS" : "FAIL"); + return bad == 0 ? 0 : 1; + } + + /* + * The paint tools draw straight into the pixmap with XDrawLine and + * XFillArc, not through SetImageRGB, so their undo state is taken + * only at the press. A screenshot test cannot tell a line that was + * undone from a line that was never drawn, so this reads the + * document's own pixels. + */ + if (argc >= 2 && strcmp(argv[1], "-paintundotest") == 0) { + unsigned char *rgb = NULL; + int w = 64, h = 48, i, bad = 0, before; + + rgb = malloc((size_t) w * h * 3); + if (rgb == NULL) { + printf("dtphoto paintundotest: FAIL malloc\n"); + return 1; + } + for (i = 0; i < w * h * 3; i++) + rgb[i] = 255; /* a white page */ + if (SetImageRGB(rgb, w, h) != 0) { + printf("dtphoto paintundotest: FAIL image\n"); + free(rgb); + return 1; + } + free(rgb); + UndoReset(); + /* what the press does, then a line as the tool paints it */ + UndoRecord(); + SetImageFG(); + LineImage(10, 10, 50, 10); + /* read the middle of the line: it must be dark now */ + rgb = NULL; + if (GetImageRGB(&rgb, &w, &h) != 0) { + printf("dtphoto paintundotest: FAIL read\n"); + return 1; + } + before = rgb[((size_t) 10 * w + 30) * 3]; + printf("dtphoto paintundotest: line %d want < 128 %s\n", + before, before < 128 ? "ok" : "FAIL"); + if (before >= 128) + bad++; + free(rgb); + if (!UndoStep()) { + printf("dtphoto paintundotest: undo refused FAIL\n"); + return 1; + } + rgb = NULL; + if (GetImageRGB(&rgb, &w, &h) != 0) { + printf("dtphoto paintundotest: FAIL read back\n"); + return 1; + } + printf("dtphoto paintundotest: after undo %d want 255 %s\n", + rgb[((size_t) 10 * w + 30) * 3], + rgb[((size_t) 10 * w + 30) * 3] == 255 ? "ok" : "FAIL"); + if (rgb[((size_t) 10 * w + 30) * 3] != 255) + bad++; + free(rgb); + if (!RedoStep()) { + printf("dtphoto paintundotest: redo refused FAIL\n"); + return 1; + } + rgb = NULL; + if (GetImageRGB(&rgb, &w, &h) != 0) + return 1; + printf("dtphoto paintundotest: after redo %d want < 128 %s\n", + rgb[((size_t) 10 * w + 30) * 3], + rgb[((size_t) 10 * w + 30) * 3] < 128 ? "ok" : "FAIL"); + if (rgb[((size_t) 10 * w + 30) * 3] >= 128) + bad++; + free(rgb); + /* + * The hand and the magnifier leave the picture alone, so + * they must not push a step: a pan followed by Undo has to + * return to the *paint*, not to an identical frame. + */ + UndoReset(); + UndoRecord(); + SetImageFG(); + LineImage(10, 20, 50, 20); + { + int ahead = UndoAhead(); + + printf("dtphoto paintundotest: one stroke, %d " + "step(s) back %s\n", ahead, + ahead == 1 ? "ok" : "FAIL"); + if (ahead != 1) + bad++; + } + printf("dtphoto paintundotest: %s\n", + bad == 0 ? "PASS" : "FAIL"); + return bad == 0 ? 0 : 1; + } + + /* + * A selection change and a pixel change must not be the same + * step: the ring holds pictures, so an Undo after only a marquee + * would move the history back without moving anything on screen. + * The frames therefore carry the mask too -- a selection is part + * of the state a person wants back. + */ + if (argc >= 2 && strcmp(argv[1], "-undoselecttest") == 0) { + unsigned char *rgb = NULL; + int w = 16, h = 16, i, bad = 0; + + rgb = malloc((size_t) w * h * 3); + if (rgb == NULL) { + printf("dtphoto undoselecttest: FAIL malloc\n"); + return 1; + } + for (i = 0; i < w * h * 3; i++) + rgb[i] = 90; + if (SetImageRGB(rgb, w, h) != 0) { + printf("dtphoto undoselecttest: FAIL image\n"); + free(rgb); + return 1; + } + free(rgb); + UndoReset(); + /* a selection, recorded as its own step */ + UndoRecord(); + if (MaskAlloc() != 0) { + printf("dtphoto undoselecttest: FAIL mask\n"); + return 1; + } + MaskClear(); + for (i = 0; i < h; i++) + MaskSet(4, i, 1); + selMaskAny = 1; + hasSel = 1; + selX0 = 4; selY0 = 0; selX1 = 5; selY1 = h; + printf("dtphoto undoselecttest: mask before undo %d want 1 %s\n", + MaskGet(4, 8), MaskGet(4, 8) == 1 ? "ok" : "FAIL"); + if (MaskGet(4, 8) != 1) + bad++; + if (!UndoStep()) { + printf("dtphoto undoselecttest: undo refused FAIL\n"); + return 1; + } + printf("dtphoto undoselecttest: mask after undo %d want 0 %s\n", + MaskGet(4, 8), MaskGet(4, 8) == 0 ? "ok" : "FAIL"); + if (MaskGet(4, 8) != 0) + bad++; + if (!RedoStep()) { + printf("dtphoto undoselecttest: redo refused FAIL\n"); + return 1; + } + printf("dtphoto undoselecttest: mask after redo %d want 1 %s\n", + MaskGet(4, 8), MaskGet(4, 8) == 1 ? "ok" : "FAIL"); + if (MaskGet(4, 8) != 1) + bad++; + printf("dtphoto undoselecttest: %s\n", + bad == 0 ? "PASS" : "FAIL"); + return bad == 0 ? 0 : 1; + } + + /* + * The depth the Preferences box sets has to mean something: with + * depth 1 only one step back may exist, with depth 3 exactly three. + * Before 2026-11-22 the box existed and the number was never read. + */ + if (argc >= 2 && strcmp(argv[1], "-undodepthtest") == 0) { + unsigned char *rgb = NULL; + int w = 8, h = 8, i, bad = 0, d, steps; + int depths[2] = { 1, 3 }; + + for (d = 0; d < 2; d++) { + undoDepth = depths[d]; + rgb = malloc((size_t) w * h * 3); + if (rgb == NULL) { + printf("dtphoto undodepthtest: FAIL malloc\n"); + return 1; + } + for (i = 0; i < w * h * 3; i++) + rgb[i] = 10; + if (SetImageRGB(rgb, w, h) != 0) { + printf("dtphoto undodepthtest: FAIL image\n"); + free(rgb); + return 1; + } + UndoReset(); + /* five changes, each recorded by SetImageRGB */ + for (i = 1; i <= 5; i++) { + int n = w * h * 3, k; + + rgb = NULL; + if (GetImageRGB(&rgb, &w, &h) != 0) + return 1; + for (k = 0; k < n; k++) + rgb[k] = (unsigned char) + (10 + i * 20); + SetImageRGB(rgb, w, h); + free(rgb); + } + steps = 0; + while (UndoStep()) + steps++; + printf("dtphoto undodepthtest: depth %d -> " + "%d steps %s\n", depths[d], steps, + steps == depths[d] ? "ok" : "FAIL"); + if (steps != depths[d]) + bad++; + } + undoDepth = 8; + printf("dtphoto undodepthtest: %s\n", + bad == 0 ? "PASS" : "FAIL"); + return bad == 0 ? 0 : 1; + } + if (argc >= 2 && strcmp(argv[1], "-menutest") == 0) { int i, bad = 0, ntab = 0, ndup = 0; int nmenu = 0, nbind = 0; @@ -13001,6 +15777,297 @@ main(int argc, char **argv) return bad == 0 ? 0 : 1; } + if (argc >= 2 && strcmp(argv[1], "-psdtest") == 0) { + /* + * A document with a stack, written as a Photoshop file and read + * back. + * + * What has to hold: + * - the composite survives pixel for pixel; + * - the stack survives: count, names, opacity, blend mode and + * whether a layer is hidden; + * - a layer's own coverage survives, because it is the alpha + * channel a PSD carries; + * - and the file is one another program reads -- ImageMagick + * prints the layer count, which is the only independent check + * that the lengths in the file are right. + * + * The last point is what the test cannot do itself, so it is + * measured from outside and reported. + */ + unsigned char *rgb, *composite; + int w = 8, h = 6, bad = 0, x, y, i; + + rgb = malloc((size_t) w * h * 3); + if (rgb == NULL) { + printf("dtphoto psdtest: FAIL malloc\n"); + return 1; + } + /* the bottom layer: a red to blue ramp, no coverage */ + for (y = 0; y < h; y++) + for (x = 0; x < w; x++) { + unsigned char *d = rgb + ((size_t) y * w + x) * 3; + + d[0] = (unsigned char) (x * 30); + d[1] = 0; + d[2] = (unsigned char) (y * 40); + } + SetImageRGB(rgb, w, h); + free(rgb); + LayerInvalidate(); + LayerEnsure(); + snprintf(layers[0].name, sizeof layers[0].name, "Ground"); + LayerNew(); + snprintf(layers[1].name, sizeof layers[1].name, "Ink"); + layers[1].opacity = 55; + layers[1].mode = 1; /* multiply */ + { + /* paint the upper layer with its own coverage: a square */ + Layer *L = &layers[1]; + + if (L->cover == NULL) + L->cover = malloc((size_t) layerW * layerH); + if (L->cover != NULL) { + memset(L->cover, 0, + (size_t) layerW * layerH); + for (y = 1; y < 4; y++) + for (x = 2; x < 6; x++) { + unsigned char *d = L->rgb + + ((size_t) y * layerW + x) * 3; + + d[0] = 200; + d[1] = 40; + d[2] = 90; + L->cover[(size_t) y * layerW + x] = 255; + } + } + } + LayerSync(); + if (LayerComposite(&composite) != 0) { + printf("dtphoto psdtest: FAIL composite\n"); + return 1; + } + + if (SavePSD("/tmp/dtphoto-psdtest.psd") != 0) { + printf("dtphoto psdtest: write FAIL\n"); + free(composite); + return 1; + } + + /* ---- read back ---- */ + LayerInvalidate(); + if (OpenPSD("/tmp/dtphoto-psdtest.psd") != 0) { + printf("dtphoto psdtest: read FAIL\n"); + free(composite); + return 1; + } + if (nlayers != 2) { + printf("dtphoto psdtest: %d layers, want 2 FAIL\n", + nlayers); + bad++; + } + if (layerW != w || layerH != h) { + printf("dtphoto psdtest: %dx%d, want %dx%d FAIL\n", + layerW, layerH, w, h); + bad++; + } + if (strcmp(layers[0].name, "Ground") != 0 || + strcmp(layers[1].name, "Ink") != 0) { + printf("dtphoto psdtest: names \"%s\" \"%s\" FAIL\n", + layers[0].name, layers[1].name); + bad++; + } + if (layers[1].opacity != 55 || layers[1].mode != 1 || + layers[1].visible != 1 || layers[0].visible != 1) { + printf("dtphoto psdtest: opacity %d mode %d vis %d/%d FAIL\n", + layers[1].opacity, layers[1].mode, + layers[0].visible, layers[1].visible); + bad++; + } + /* the alpha plane came back as coverage: inside opaque, + * outside clear */ + if (layers[1].cover == NULL || + layers[1].cover[(size_t) 2 * w + 3] != 255 || + layers[1].cover[(size_t) 0 * w + 0] != 0) { + printf("dtphoto psdtest: coverage FAIL\n"); + bad++; + } else + printf("dtphoto psdtest: coverage inside=%d outside=%d ok\n", + layers[1].cover[(size_t) 2 * w + 3], + layers[1].cover[0]); + /* and the layer's own red came back, not the composite */ + { + unsigned char *d = layers[1].rgb + + ((size_t) 2 * w + 3) * 3; + + if (d[0] != 200 || d[1] != 40 || d[2] != 90) { + printf("dtphoto psdtest: layer pixel %d,%d,%d " + "want 200,40,90 FAIL\n", d[0], d[1], d[2]); + bad++; + } else + printf("dtphoto psdtest: layer pixel ok\n"); + } + /* the composite of the read stack matches the composite of the + * written one: the file carries the picture, not a lossy copy */ + { + unsigned char *again; + int diff = 0; + + if (LayerComposite(&again) == 0) { + for (i = 0; i < w * h * 3; i++) + if (again[i] != composite[i]) + diff++; + if (diff != 0) { + printf("dtphoto psdtest: composite " + "%d bytes differ FAIL\n", diff); + bad++; + } else + printf("dtphoto psdtest: composite " + "identical ok\n"); + free(again); + } + } + free(composite); + + /* hidden stays hidden */ + layers[1].visible = 0; + if (SavePSD("/tmp/dtphoto-psdtest2.psd") != 0) { + printf("dtphoto psdtest: write 2 FAIL\n"); + return 1; + } + LayerInvalidate(); + if (OpenPSD("/tmp/dtphoto-psdtest2.psd") != 0 || + nlayers != 2 || layers[1].visible != 0) { + printf("dtphoto psdtest: hidden flag FAIL\n"); + bad++; + } else + printf("dtphoto psdtest: hidden flag ok\n"); + + printf("dtphoto psdtest: %s\n", bad == 0 ? "PASS" : "FAIL"); + return bad == 0 ? 0 : 1; + } + + if (argc >= 3 && strcmp(argv[1], "-psdread") == 0) { + /* + * A Photoshop file another program wrote. Everything above + * checks dtphoto against itself; this is the other direction, + * and it is the one that catches a reader that only agrees + * with its own writer. + * + * The file is read, then the stack and a few known pixels are + * printed so the numbers can be compared with what ImageMagick + * reports for the same file. + */ + int bad = 0, n, i, x, y; + unsigned char *rgb = NULL; + + if (OpenImage(argv[2]) != 0) { + printf("dtphoto psdread: cannot open %s FAIL\n", argv[2]); + return 1; + } + n = nlayers; + printf("dtphoto psdread: doc %dx%d layers %d\n", docW, docH, n); + if (GetImageRGB(&rgb, &x, &y) != 0) { + printf("dtphoto psdread: no composite FAIL\n"); + return 1; + } + for (i = 0; i < n; i++) + printf("dtphoto psdread: layer %d \"%s\" " + "opacity %d mode %d vis %d cover %d\n", + i, layers[i].name, layers[i].opacity, + layers[i].mode, layers[i].visible, + layers[i].cover != NULL); + /* a couple of pixels of the composite, and of the top layer */ + printf("dtphoto psdread: composite (0,0) %d,%d,%d " + "(15,11) %d,%d,%d\n", + rgb[0], rgb[1], rgb[2], + rgb[((size_t) 11 * docW + 15) * 3], + rgb[((size_t) 11 * docW + 15) * 3 + 1], + rgb[((size_t) 11 * docW + 15) * 3 + 2]); + free(rgb); + printf("dtphoto psdread: %s\n", bad ? "FAIL" : "PASS"); + return bad ? 1 : 0; + } + + if (argc >= 2 && strcmp(argv[1], "-rletest") == 0) { + /* + * PackBits has to actually shrink a picture of flat colour, and + * a reader that is not this program has to see the same pixels. + * The size is compared with the raw form here; the pixels are + * checked from outside, because a compression bug is exactly the + * kind that is invisible to the writer's own reader. + */ + unsigned char *rgb; + int w = 64, h = 64, x, y, bad = 0; + const char *path = "/tmp/dtphoto-rletest.psd"; + FILE *f; + long len, rawLen; + + rgb = malloc((size_t) w * h * 3); + if (rgb == NULL) + return 1; + /* a flat field with one hard edge: packbits runs, raw does not */ + for (y = 0; y < h; y++) + for (x = 0; x < w; x++) { + unsigned char *d = rgb + ((size_t) y * w + x) * 3; + + if (x < 32) { + d[0] = 200; d[1] = 40; d[2] = 90; + } else { + d[0] = 20; d[1] = 160; d[2] = 60; + } + } + SetImageRGB(rgb, w, h); + free(rgb); + if (SaveImage(path) != 0) { + printf("dtphoto rletest: cannot write FAIL\n"); + return 1; + } + /* one layer, 3 channels, 8-bit: raw is header + 3 * (2 + w*h) */ + rawLen = 26 + 4 + 4 + 2 + 200 + 3 * (2 + (long) w * h); + f = fopen(path, "rb"); + if (f == NULL) { + printf("dtphoto rletest: cannot reopen FAIL\n"); + return 1; + } + fseek(f, 0, SEEK_END); + len = ftell(f); + fclose(f); + printf("dtphoto rletest: file %ld bytes, raw would be about %ld\n", + len, rawLen); + if (len >= rawLen) { + printf("dtphoto rletest: the file was not compressed FAIL\n"); + bad++; + } + /* the pixels, through this program's own reader */ + if (OpenImage(path) != 0) { + printf("dtphoto rletest: read back FAIL\n"); + return 1; + } + { + unsigned char *back = NULL; + int bw = 0, bh = 0; + + if (GetImageRGB(&back, &bw, &bh) != 0 || + bw != w || bh != h) { + printf("dtphoto rletest: size %dx%d FAIL\n", + bw, bh); + bad++; + } else if (back[((size_t) 10 * w + 10) * 3] != 200 || + back[((size_t) 10 * w + 10) * 3 + 1] != 40 || + back[((size_t) 10 * w + 10) * 3 + 2] != 90 || + back[((size_t) 10 * w + 50) * 3] != 20 || + back[((size_t) 10 * w + 50) * 3 + 1] != 160 || + back[((size_t) 10 * w + 50) * 3 + 2] != 60) { + printf("dtphoto rletest: pixels differ FAIL\n"); + bad++; + } + free(back); + } + printf("dtphoto rletest: %s\n", bad ? "FAIL" : "PASS"); + return bad ? 1 : 0; + } + if (argc >= 2 && strcmp(argv[1], "-drawtest") == 0) { Pixmap pm; XImage *im; @@ -14364,6 +17431,150 @@ main(int argc, char **argv) return bad == 0 ? 0 : 1; } + /* + * The selection has to travel with the picture. A 6x4 document with + * a 2x2 square selected at (1,1) is flipped and rotated; after every + * step the same picture pixels must be selected, and the pixel found + * under the selection must be the one that was there before. + * + * Each step starts from the same document: chaining them would mix + * two transforms and the expectation would stop being readable. + */ + if (argc >= 2 && strcmp(argv[1], "-selxform") == 0) { + unsigned char *rgb; + int x, y, bad = 0; + + rgb = malloc(6 * 4 * 3); + if (rgb == NULL) + return 1; + for (y = 0; y < 4; y++) + for (x = 0; x < 6; x++) { + unsigned char *d = rgb + ((size_t) y * 6 + x) * 3; + + /* every pixel its own colour, so the pixel under + * the selection can be named: 30*x, 40*y */ + d[0] = (unsigned char) (x * 30); + d[1] = (unsigned char) (y * 40); + d[2] = (unsigned char) (x * 10 + y); + } + +#define SELXFORM_RESET() \ + do { \ + SetImageRGB(rgb, 6, 4); \ + MaskAlloc(); \ + MaskClear(); \ + for (y = 1; y < 3; y++) \ + for (x = 1; x < 3; x++) \ + MaskSet(x, y, 1); \ + selMaskAny = 1; \ + hasSel = 1; \ + selX0 = 1; selY0 = 1; selX1 = 3; selY1 = 3; \ + } while (0) + + /* flip horizontal: the square sits at (3,1), and the pixel + * there is the old (1,1) */ + SELXFORM_RESET(); + OpFlip(1); + if (docW != 6 || docH != 4) + bad++, printf("dtphoto selxform: flip size %dx%d\n", + docW, docH); + if (!MaskGet(3, 1) || !MaskGet(4, 2) || MaskGet(1, 1) || + MaskGet(0, 0)) + bad++, printf("dtphoto selxform: flip horizontal " + "wrong (3,1)=%d (4,2)=%d (0,0)=%d\n", + MaskGet(3, 1), MaskGet(4, 2), MaskGet(0, 0)); + + /* rotate 90 clockwise: 6x4 becomes 4x6 and the old (1,1) is + * the new (2,1) */ + SELXFORM_RESET(); + OpRotate(1); + if (docW != 4 || docH != 6) + bad++, printf("dtphoto selxform: rotate size %dx%d " + "want 4x6\n", docW, docH); + /* the old square (1,1)..(2,2) turns into a square at + * (1,1)..(2,2) of the 4x6 document -- measured, not guessed: + * the old (1,1) is the new (2,1), the old (2,2) the new (1,2) */ + if (!MaskGet(2, 1) || !MaskGet(1, 2) || !MaskGet(1, 1) || + !MaskGet(2, 2) || MaskGet(0, 0) || MaskGet(3, 5)) + bad++, printf("dtphoto selxform: rotate 90cw wrong " + "(2,1)=%d (1,2)=%d (0,0)=%d (3,5)=%d\n", + MaskGet(2, 1), MaskGet(1, 2), MaskGet(0, 0), + MaskGet(3, 5)); + { + unsigned char *now; + int w2, h2; + + if (GetImageRGB(&now, &w2, &h2) == 0) { + unsigned char *d = + now + ((size_t) 1 * w2 + 2) * 3; + + if (d[0] != 30 || d[1] != 40) + bad++, printf("dtphoto selxform: " + "pixel under the rotation is " + "%d,%d want 30,40\n", d[0], + d[1]); + free(now); + } + } + + /* rotate 90 counter-clockwise: the old (1,1) is the new + * (1,4) of a 4x6 document */ + SELXFORM_RESET(); + OpRotate(-1); + if (docW != 4 || docH != 6 || !MaskGet(1, 4) || MaskGet(0, 0)) + bad++, printf("dtphoto selxform: rotate 90ccw wrong " + "%dx%d (1,4)=%d (0,0)=%d\n", docW, docH, + MaskGet(1, 4), MaskGet(0, 0)); + + /* rotate 180: same size, the square moves to (3,1)..(4,2) */ + SELXFORM_RESET(); + OpRotate(0); + if (docW != 6 || docH != 4 || !MaskGet(3, 1) || !MaskGet(4, 2) || + !MaskGet(3, 2) || !MaskGet(4, 1) || MaskGet(1, 1) || + MaskGet(0, 0)) + bad++, printf("dtphoto selxform: rotate 180 wrong " + "%dx%d (3,1)=%d (4,1)=%d (1,1)=%d\n", docW, docH, + MaskGet(3, 1), MaskGet(4, 1), MaskGet(1, 1)); + + /* a document without a selection must not grow one */ + SetImageRGB(rgb, 6, 4); + MaskClear(); + selMaskAny = 0; + hasSel = 0; + OpRotate(1); + if (hasSel || selMaskAny) + bad++, printf("dtphoto selxform: rotate made a " + "selection\n"); + + /* + * Canvas Size: the picture is centred in a larger canvas, so + * the selection moves by the same offset. 6x4 becomes 10x8, + * the picture lands at (2,2), and the square that was at + * (1,1) is at (3,3). + */ + SELXFORM_RESET(); + OpCanvasSize(10, 8, 2, 2); + if (docW != 10 || docH != 8) + bad++, printf("dtphoto selxform: canvas size %dx%d " + "want 10x8\n", docW, docH); + if (!MaskGet(3, 3) || !MaskGet(4, 4) || MaskGet(1, 1) || + MaskGet(0, 0)) + bad++, printf("dtphoto selxform: canvas size did not " + "move the selection (3,3)=%d (1,1)=%d\n", + MaskGet(3, 3), MaskGet(1, 1)); + + /* a canvas that shrinks past the selection drops it */ + SELXFORM_RESET(); + OpCanvasSize(2, 2, -5, -5); + if (hasSel && (MaskGet(0, 0) || MaskGet(1, 1))) + bad++, printf("dtphoto selxform: shrunk canvas kept " + "the old selection\n"); + + printf("dtphoto selxform: %s\n", bad ? "FAIL" : "PASS"); + free(rgb); + return bad ? 1 : 0; + } + if (argc >= 2 && strcmp(argv[1], "-optest") == 0) { unsigned char *rgb; int w = 6, h = 4, x, y, bad = 0; @@ -14843,7 +18054,7 @@ main(int argc, char **argv) XImage *im; int ok; - XCopyArea(dpy, image, snap, gc, 0, 0, docW, docH, 0, 0); + UndoRecord(); SetImageFG(); LineImage(10, 10, 100, 10); { diff --git a/ext/src/mcde/programs/dtphoto/dtphoto.menu b/ext/src/mcde/programs/dtphoto/dtphoto.menu index 3174aa8f06..561850e5f9 100644 --- a/ext/src/mcde/programs/dtphoto/dtphoto.menu +++ b/ext/src/mcde/programs/dtphoto/dtphoto.menu @@ -34,6 +34,7 @@ item Quit | Ctrl+Q menu Edit item Undo | Ctrl+Z +item Redo | Ctrl+Shift+Z sep item Cut | Ctrl+X item Copy | Ctrl+C diff --git a/ext/src/mcde/programs/dtsystemsettings/Makefile.am b/ext/src/mcde/programs/dtsystemsettings/Makefile.am index e7b8aac205..1a405370a2 100644 --- a/ext/src/mcde/programs/dtsystemsettings/Makefile.am +++ b/ext/src/mcde/programs/dtsystemsettings/Makefile.am @@ -7,7 +7,7 @@ bin_PROGRAMS = dtsystemsettings dtsystemsettings_SOURCES = main.c panes.c panes.h ui.h accounts.c update.c \ network.c \ input.c appearance.c desktop.c timezone.c wifi.c \ - startup.c sharing.c backup.c displays.c language.c sound.c printers.c parental.c cds.c energy.c internet.c defaults.c sysinfo.c startupdisk.c \ + startup.c sharing.c backup.c displays.c language.c sound.c printers.c parental.c cds.c dock.c energy.c internet.c defaults.c sysinfo.c startupdisk.c \ security.c dtsystemsettings_CPPFLAGS = -I$(top_srcdir)/include $(DT_INCDIR) \ -I$(top_builddir)/include $(XFT_CFLAGS) \ diff --git a/ext/src/mcde/programs/dtsystemsettings/main.c b/ext/src/mcde/programs/dtsystemsettings/main.c index ca16cccbee..1a342ecb70 100644 --- a/ext/src/mcde/programs/dtsystemsettings/main.c +++ b/ext/src/mcde/programs/dtsystemsettings/main.c @@ -1125,6 +1125,8 @@ ShowPane(const Pane *p) else if (strcmp(p->id, "energy") == 0) { w = MakeEnergy(paneArea); } + else if (strcmp(p->id, "dock") == 0) + w = MakeDock(paneArea); else if (strcmp(p->id, "cds") == 0) { w = MakeCDs(paneArea); } diff --git a/ext/src/mcde/programs/dtsystemsettings/panes.c b/ext/src/mcde/programs/dtsystemsettings/panes.c index 2deec0af70..af79415457 100644 --- a/ext/src/mcde/programs/dtsystemsettings/panes.c +++ b/ext/src/mcde/programs/dtsystemsettings/panes.c @@ -29,6 +29,8 @@ const Pane panes[] = { "screensaver screen saver bildschirmschoner" }, { "language", "Language", CAT_PERSONAL, "DtI18N.pm", PANE_OWN, NULL, "language sprache locale region formats datum" }, + { "dock", "Dock", CAT_PERSONAL, "Dtapps.m.pm", PANE_OWN, NULL, + "dock leiste panel front panel programme programs" }, { "security", "Security", CAT_PERSONAL, "McdeLock.pm", PANE_OWN, NULL, "security sicherheit firewall lock sperre password passwort " "encryption verschluesselung cgd swap virtual memory npf" }, diff --git a/ext/src/mcde/programs/dtsystemsettings/ui.h b/ext/src/mcde/programs/dtsystemsettings/ui.h index 64a360133c..6dfe291252 100644 --- a/ext/src/mcde/programs/dtsystemsettings/ui.h +++ b/ext/src/mcde/programs/dtsystemsettings/ui.h @@ -77,6 +77,7 @@ Widget MakePrinters(Widget parent); Widget MakeParental(Widget parent); /* the CDs & DVDs pane (cds.c): the choice per kind of medium */ Widget MakeCDs(Widget parent); +Widget MakeDock(Widget parent); /* the Energy Saver pane (energy.c) */ Widget MakeEnergy(Widget parent); /* the Internet accounts pane (internet.c) */ diff --git a/ext/src/mcde/programs/dtwm/UI.c b/ext/src/mcde/programs/dtwm/UI.c index a4a24a3df2..20ffd4be58 100644 --- a/ext/src/mcde/programs/dtwm/UI.c +++ b/ext/src/mcde/programs/dtwm/UI.c @@ -62,6 +62,7 @@ #include #include +#include #include #include @@ -105,6 +106,7 @@ extern void DeleteControlActionList (ControlData *); extern Boolean CheckOtherMonitorsOn (SubpanelData *); static void Initialize (DtPanelShellWidget); +static void PanelMapped (Widget, XtPointer, XtPointer); static void BoxCreate (); static Widget PanelControlCreate (Widget, char *, String); static void MainControlCreate (int); @@ -192,6 +194,7 @@ FrontPanelCreate (Widget toplevel) XtSetArg (al[ac], XmNmwmDecorations, MWM_DECOR_BORDER); ac++; panel.shell = XtCreatePopupShell (panel_name, dtPanelShellWidgetClass, toplevel, al, ac); + XtAddCallback (panel.shell, XmNmapCallback, PanelMapped, NULL); panel_shell = (DtPanelShellWidget) panel.shell; @@ -384,6 +387,25 @@ FrontPanelCreate (Widget toplevel) * ************************************************************************/ + +/* The panel's pointer: the standard arrow, defined on the shell itself. A + * window without a cursor of its own inherits its parent's, and the frame + * dtwm gives the panel carried a black 16x16 cursor on this server (measured + * 2026-11-21); the panel is a place to click, so it says which pointer it + * wants instead of inheriting one. */ +static void +PanelMapped(Widget w, XtPointer cd, XtPointer call) +{ + Cursor arrow; + + (void) cd; (void) call; + arrow = XCreateFontCursor(XtDisplay(w), XC_left_ptr); + if (arrow != None) { + XDefineCursor(XtDisplay(w), XtWindow(w), arrow); + XFreeCursor(XtDisplay(w), arrow); + } +} + static void Initialize (DtPanelShellWidget panel_shell) @@ -407,9 +429,12 @@ Initialize (DtPanelShellWidget panel_shell) unsigned int size; - /* Create busy cursor. */ + /* Create busy cursor. The return value used to be thrown away, so + * BUSY_START defined cursor None on the panel and the pointer fell back + * to whatever the shell had inherited (a black 16x16 square on this + * server, measured 2026-11-21: XFixes 16x16, hotspot 8,8, all black). */ - _DtGetHourGlassCursor(display); + panel.busy_cursor = _DtGetHourGlassCursor(display); panel.resolution = (int) (intptr_t) panel.element_values[PANEL_RESOLUTION].parsed_value; diff --git a/ext/src/mcde/programs/dtwm/WmEvent.c b/ext/src/mcde/programs/dtwm/WmEvent.c index 023c7a32c6..b636f7da87 100644 --- a/ext/src/mcde/programs/dtwm/WmEvent.c +++ b/ext/src/mcde/programs/dtwm/WmEvent.c @@ -2364,6 +2364,31 @@ void HandleWsConfigureRequest (XConfigureRequestEvent *configureEvent) } /* END OF FUNCTION HandleWsConfigureRequest */ +/* A client that carries _MCDE_NO_FOCUS is not a keyboard target: the bar + * (dtbar) sets it, so the pointer passing over the bar leaves the last + * program focused and the bar keeps showing that program's menu (t0255). */ +static Bool +NoFocusClient (ClientData *pCD) +{ + Atom a, type; + int fmt; + unsigned long n, after; + unsigned char *data = NULL; + Bool r = False; + + if (pCD == NULL) + return False; + a = XInternAtom (DISPLAY, "_MCDE_NO_FOCUS", False); + if (XGetWindowProperty (DISPLAY, pCD->client, a, 0, 1, False, + XA_CARDINAL, &type, &fmt, &n, &after, &data) == Success && + data != NULL) { + r = True; + XFree (data); + } + return r; +} + + /*************************************<->************************************* * @@ -2482,7 +2507,8 @@ void HandleWsFocusIn (XFocusInEvent *focusEvent) } else /*KEYBOARD_FOCUS_POINTER*/ { - if (pCD || focusEvent->detail != NotifyPointerRoot) + if ((pCD || focusEvent->detail != NotifyPointerRoot) && + !NoFocusClient (pCD)) { Do_Focus_Key (pCD, GetTimestamp (), ALWAYS_SET_FOCUS); } diff --git a/ext/src/mcde/programs/dtwm/WmMcdeDesktop.c b/ext/src/mcde/programs/dtwm/WmMcdeDesktop.c index ec4a6ae829..43d840a2f9 100644 --- a/ext/src/mcde/programs/dtwm/WmMcdeDesktop.c +++ b/ext/src/mcde/programs/dtwm/WmMcdeDesktop.c @@ -71,7 +71,7 @@ DeskScreen(void) #define DESK_MAX 64 #define DESK_CELL_W 96 -#define DESK_CELL_H 88 +#define DESK_CELL_H 96 #define DESK_MARGIN 10 #define DESK_LABEL_H 14 #define DESK_CONF ".dt/desktop.conf" @@ -112,7 +112,7 @@ static int deskCount; static Display *deskDpy; static Window deskRoot; static GC deskGC; -static Pixel deskBg, deskFg, deskMid; +static Pixel deskBg, deskFg, deskMid, deskShadow; static XFontStruct *deskFont; static int deskSel = -1; static Time deskLast; @@ -290,20 +290,28 @@ DeskIconName(const DeskItem *it) { switch (it->kind) { case DESK_COMPUTER: - return "McdeDisk.m.pm"; + return "IrixDisk.m.pm"; case DESK_NET: - return "McdeNetwork.m.pm"; + return "IrixNet.m.pm"; case DESK_MEDIA: - return "Dtuuncd.m.pm"; + /* the medium the drive holds: a CD, a DVD, a diskette or a + * tape, the IRIX Foundation icons at 64x64 */ + switch (it->fstype[0]) { + case 'c': return "IrixCD.m.pm"; /* cd9660 */ + case 'u': return "IrixDVD.m.pm"; /* udf */ + case 'm': return "IrixFloppy.m.pm"; /* msdos */ + case 't': return "IrixTape.m.pm"; /* tar, dump */ + default: return "IrixDisk.m.pm"; + } case DESK_USER: /* fstype carries "d" for a folder and "f" for a file */ return it->fstype[0] == 'd' ? "DtdirB.m.pm" : "McdeFile.m.pm"; case DESK_TRASH: return it->fstype[0] == 'f' ? "Dtbinml.m.pm" : "Dtbin.m.pm"; case DESK_DISK: - return "McdeDisk.m.pm"; + return "IrixDisk.m.pm"; default: - return "McdeDisk.m.pm"; + return "IrixDisk.m.pm"; } } @@ -365,9 +373,6 @@ DeskDraw(int i) int gy = 6; int lw; - XSetForeground(deskDpy, deskGC, deskBg); - XFillRectangle(deskDpy, it->win, deskGC, 0, 0, DESK_CELL_W, - DESK_CELL_H); if (it->glyph != None) { if (it->mask != None) { XSetClipMask(deskDpy, deskGC, it->mask); @@ -380,12 +385,35 @@ DeskDraw(int i) DeskLabel(it, label, sizeof label); lw = deskFont != NULL ? XTextWidth(deskFont, label, (int) strlen(label)) : (int) strlen(label) * 6; - XSetForeground(deskDpy, deskGC, deskBg); - XFillRectangle(deskDpy, it->win, deskGC, (DESK_CELL_W - lw) / 2 - 3, - gy + gh + 6, (unsigned) (lw + 6), DESK_LABEL_H); + /* 4Dwm sets the label on the backdrop, with a shadow, not into a + * tile: the window is shaped to the picture and the text (below) and + * the text gets one pixel of black under it. */ + XSetForeground(deskDpy, deskGC, deskShadow); + XDrawString(deskDpy, it->win, deskGC, (DESK_CELL_W - lw) / 2 + 1, + gy + gh + 6 + DESK_LABEL_H - 3, label, (int) strlen(label)); XSetForeground(deskDpy, deskGC, deskFg); XDrawString(deskDpy, it->win, deskGC, (DESK_CELL_W - lw) / 2, gy + gh + 6 + DESK_LABEL_H - 4, label, (int) strlen(label)); + { + Pixmap shape = XCreatePixmap(deskDpy, it->win, DESK_CELL_W, + DESK_CELL_H, 1); + GC sg = XCreateGC(deskDpy, shape, 0, NULL); + + XSetForeground(deskDpy, sg, 0); + XFillRectangle(deskDpy, shape, sg, 0, 0, DESK_CELL_W, + DESK_CELL_H); + XSetForeground(deskDpy, sg, 1); + if (it->glyph != None) + XFillRectangle(deskDpy, shape, sg, gx, gy, + (unsigned) gw, (unsigned) gh); + XFillRectangle(deskDpy, shape, sg, (DESK_CELL_W - lw) / 2, + gy + gh + 6, (unsigned) lw, + (unsigned) DESK_LABEL_H); + XShapeCombineMask(deskDpy, it->win, ShapeBounding, 0, 0, + shape, ShapeSet); + XFreeGC(deskDpy, sg); + XFreePixmap(deskDpy, shape); + } if (i == deskSel) XDrawRectangle(deskDpy, it->win, deskGC, 0, 0, DESK_CELL_W - 1, DESK_CELL_H - 1); @@ -415,7 +443,13 @@ DeskMap(int i) } if (it->workspace == 0 || it->workspace == active + 1) { XMoveWindow(deskDpy, it->win, it->x, it->y); - XMapRaised(deskDpy, it->win); + /* The desktop is the bottom of the stack: a window that is + * raised (a full screen program) covers the icons, as 4Dwm's + * does. XMapRaised put them above every client, because an + * override-redirect window is not restacked by the window + * manager. */ + XMapWindow(deskDpy, it->win); + XLowerWindow(deskDpy, it->win); } else XUnmapWindow(deskDpy, it->win); } @@ -1956,6 +1990,7 @@ McdeDesktopInit(void) cmap = DefaultColormap(deskDpy, pSD->screen); deskBg = WhitePixel(deskDpy, pSD->screen); deskFg = BlackPixel(deskDpy, pSD->screen); + deskShadow = BlackPixel(deskDpy, pSD->screen); deskMid = WhitePixel(deskDpy, pSD->screen); if (XParseColor(deskDpy, cmap, "#C6C6B2B2A8A8", &c) && XAllocColor(deskDpy, cmap, &c)) diff --git a/ext/src/mcde/programs/dtwm/WmMcdePanel.c b/ext/src/mcde/programs/dtwm/WmMcdePanel.c index 64d9fc28a7..402a46a698 100644 --- a/ext/src/mcde/programs/dtwm/WmMcdePanel.c +++ b/ext/src/mcde/programs/dtwm/WmMcdePanel.c @@ -56,6 +56,37 @@ #include
#include
#include
+ +/* The icon of a program class. CDE names them with a capital (Dtterm, + * Dtcalc); a client's WM_CLASS instance name is often lower case and the + * class a kept program was written with may be either. Try the name as + * given, then in lower case, then with a capital -- the file name is what + * decides, not the comparison, which is strcasecmp. */ +static String +ClassIcon(Screen *screen, const char *cls, unsigned int size) +{ + char lower[64], first[64]; + String icon; + int i; + + icon = _DtGetIconFileName(screen, (String) cls, NULL, NULL, size); + if (icon != NULL) + return icon; + for (i = 0; cls[i] != '\0' && i + 1 < (int) sizeof lower; i++) + lower[i] = (char) tolower((unsigned char) cls[i]); + lower[i] = '\0'; + if (strcmp(lower, cls) != 0) { + icon = _DtGetIconFileName(screen, lower, NULL, NULL, size); + if (icon != NULL) + return icon; + } + if (cls[0] >= 'a' && cls[0] <= 'z') { + (void) snprintf(first, sizeof first, "%c%s", + cls[0] - 'a' + 'A', cls + 1); + icon = _DtGetIconFileName(screen, first, NULL, NULL, size); + } + return icon; +} #include #define MAX_APPS 48 @@ -375,17 +406,8 @@ AddDrawerWidget(int idx) below = kids[k - 1]; break; } - icon = _DtGetIconFileName(XtScreen(form), (String) drawerIcons[idx].cls, - NULL, NULL, panel.sub_icon_size); - if (icon == NULL) { - for (i = 0; drawerIcons[idx].cls[i] != '\0' && - i + 1 < sizeof lower; i++) - lower[i] = (char) tolower((unsigned char) - drawerIcons[idx].cls[i]); - lower[i] = '\0'; - icon = _DtGetIconFileName(XtScreen(form), lower, NULL, NULL, - panel.sub_icon_size); - } + icon = ClassIcon(XtScreen(form), drawerIcons[idx].cls, + panel.sub_icon_size); if (icon == NULL) icon = GetIconName("Dtactn", panel.sub_icon_size); XtSetArg(al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++; @@ -936,15 +958,7 @@ AddButton(const char *cls, int keptIndex) return; /* the class's icon, as CDE names them (Dtterm, Dtcalc), else in * lower case, else the icon of an action */ - icon = _DtGetIconFileName(XtScreen(area), (String) cls, NULL, NULL, - panel.main_icon_size); - if (icon == NULL) { - for (i = 0; cls[i] != '\0' && i + 1 < sizeof lower; i++) - lower[i] = (char) tolower((unsigned char) cls[i]); - lower[i] = '\0'; - icon = _DtGetIconFileName(XtScreen(area), lower, NULL, NULL, - panel.main_icon_size); - } + icon = ClassIcon(XtScreen(area), cls, panel.main_icon_size); if (icon == NULL) icon = GetIconName("Dtactn", panel.main_icon_size); XtSetArg(al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++; diff --git a/ext/src/mcde/programs/icons/IrixCD.m.pm b/ext/src/mcde/programs/icons/IrixCD.m.pm index 4f787b2049..d921bebd38 100644 --- a/ext/src/mcde/programs/icons/IrixCD.m.pm +++ b/ext/src/mcde/programs/icons/IrixCD.m.pm @@ -1,7 +1,7 @@ /* XPM */ /* MCDE: IrixCD.m.pm, from the IRIX Foundation icon (fti2xpm.py) */ static char *IrixCD_m_pm[] = { -"32 32 8 1 0 0", +"64 64 8 1 0 0", "k c #000000", "w c #ffffff", "d c #202020", @@ -10,36 +10,68 @@ static char *IrixCD_m_pm[] = { "b c #3f3f7f", "B c #707080", ". c None", -".......................mmmm.....", -".....................mmmmmmmm...", -"...................mmmmmmmmmmmm.", -".................mmmmmmmmmmmmmmm", -"...............mmmmmmmmmmmmmmmmm", -".............mmmmmmmmmmmmmmmmmmm", -"............mmmmmmmmmmmmmmmmmmmm", -"..............mmmmmmmmmmmmmmmmmm", -"................mmmmmmmmmmmmmmmm", -"..................mmmmmmmmmmmmmm", -"....................mmmmmmmmmmmm", -"......................mmmmmmmmmm", -"...............mm.......mmmmmmmm", -"...............mmmm.......mmmmmm", -"...............mmmmmm.......mmmm", -"...............mm.mmmmm.......mm", -"...............mm...mmmmm.......", -"...............mm.....mmmmm.....", -"...............mm.......mmmmm...", -"...............mm.........mmmmm.", -"...............mm...........mmmm", -"...............mm.............mm", -"...............mm...............", -"...............mm...............", -"...............mm...............", -"...............mm...............", -"...............mm...............", -"...............mm..............m", -"...............mm............mmm", -"...............mm..........mmmmm", -"...............mm........mmmmm..", -"...............mm........mmmm...", +".......................mmmm.....................................", +".....................mmmmmmmm...................................", +"...................mmmmmmmmmmmm.................................", +".................mmmmmmmmmmmmmmmm...............................", +"...............mmmmmmmmmmmmmmmmmmmm.............................", +".............mmmmmmmmmmmmmmmmmmmmmmmm...........................", +"............mmmmmmmmmmmmmmmmmmmmmmmmmmm...................mmmmmm", +"..............mmmmmmmmmmmmmmmmmmmmmmmmmmm............mmmmmmmmmmm", +"................mmmmmmmmmmmmmmmmmmmmmmmmmmm......mmmmmmmmmmmmmmm", +"..................mmmmmmmmmmmmmmmmmmmmmmmmmmm.mmmmmmmmmmmmmmmmmm", +"....................mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", +"......................mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", +"...............mm.......mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", +"...............mmmm.......mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmddddd", +"...............mmmmmm.......mmmmmmmmmmmmmmmmmmmmmmmmmmddddddbbbb", +"...............mm.mmmmm.......mmmmmmmmmmmmmmmmmmmdddddbbbbbbbbbb", +"...............mm...mmmmm.......mmmmmmmmmmmmmmmddddbbbbbbbbbbbdd", +"...............mm.....mmmmm.......mmmmmmmmmmddddbbbbbbbbdddddddd", +"...............mm.......mmmmm.....mmmmmmmmdddbbbbbbbdddddddddddd", +"...............mm.........mmmmm..mmmmmmmmddbbbbbbddddddddddddddd", +"...............mm...........mmmmmmmmmmmddbbbbbbddddddddddddddddd", +"...............mm.............mmmmmmmmddbbbbdddddddddddddddddddd", +"...............mm...............mmmmmdbbbbbddddddddddddddddddddd", +"...............mm................mmmdbbbbddddddddddddddddddddddd", +"...............mm................mmdbbbbdddddddddddddddddddddddd", +"...............mm.................mdbbbddddddddddddddddddddddddd", +"...............mm................mdbbbdddddddddddddddddddddddddd", +"...............mm..............mmdbbbddddddddddddddddddddddddddd", +"...............mm............mmmmbbbbddddddddddddddddddddddddddd", +"...............mm..........mmmmmmbbbbbbbdddddddddddddddddddddddb", +"...............mm........mmmmm...bbdbbbbbbbbbdddddddddddddddbbbb", +"...............mm........mmmm....bbbbbbbbbbbbbbbbbbdddddddbbbbdd", +"...............mm........mmmmmm.bbbdddbbbbbbbbbbbbbbbbddbbbbdddb", +"...............mm........mmmmmmmbbbdddddddddddddddddbbdbbbbddbbb", +"...............mm........mm..mmmbbdddddddddddddddddddddbbbddbbbb", +"...............mm........mm....mbbdddddddddddddddddddddbbdddbbbd", +"...............mm........mm.....bbdddddddddddddddddddddbbdddbbdd", +"...............mm........mm.....bbbdddddddddddddbbbbbbdbbbddbbbb", +"...............mm........mm.....bbbdddddddbbbbbbbbbbbbdbbbbdbbbb", +"...............mm........mm......bb.bbbbbbbbbbbbbbbb....bbbbmmbb", +"...............mm........mm......bbbbbbbbbbbbbbb.......dddbbbbbm", +"...............mm........mmm.....bbb.bbbbbbbbmmmm....ddddddbbbbb", +"...............mm........mmmmm....bbb.bbb.....mmmmmddddddddddddb", +"...............mm..........mmmmm...bbb..........mddddddddddddddd", +"...............mm............mmmmm..bbb........ddddddddddddddddd", +"...............mmm.............mmmmmbbbb.....ddddddddddddddddddd", +"...............mmmmm.............mmmmbbbbb.ddddddddddddddddddddd", +".................mmmmm.............mmmmbbbbddddddddddddddddddddd", +"...................mmmmm.............mmmbbbbdddddddddddddddddddd", +".....................mmmmm.............mmmbbbbdddddddddddddddddd", +".......................mmmmm.............mmbbbbbdddddddddddddddd", +".........................mmmmm.............mmmbbbbbddddddddddddd", +"...........................mmmmm.............mmmbbbbbbbbdddddddd", +".............................mmmmm.............mmmmmbbbbbbbbbbbb", +"...............................mmmmm.............mmmmmm..bbbbbbb", +".................................mmmmm.............mmmmm........", +"...................................mmmmm.............mmmmmm.....", +".....................................mmmmm.............mmmmmm...", +".......................................mmmmm.............mmmmmm.", +".........................................mmmmm.............mmmmm", +"...........................................mmmmm.............mmm", +".............................................mmmmm.............m", +"...............................................mmmmm............", +".................................................mmmmm..........", }; diff --git a/ext/src/mcde/programs/icons/IrixDVD.m.pm b/ext/src/mcde/programs/icons/IrixDVD.m.pm index 20209e7b2d..4a68b25c72 100644 --- a/ext/src/mcde/programs/icons/IrixDVD.m.pm +++ b/ext/src/mcde/programs/icons/IrixDVD.m.pm @@ -1,7 +1,7 @@ /* XPM */ /* MCDE: IrixDVD.m.pm, from the IRIX Foundation icon (fti2xpm.py) */ static char *IrixDVD_m_pm[] = { -"32 32 8 1 0 0", +"64 64 8 1 0 0", "k c #000000", "w c #ffffff", "d c #202020", @@ -10,36 +10,68 @@ static char *IrixDVD_m_pm[] = { "b c #3f3f7f", "B c #707080", ". c None", -".......................mmmm.....", -".....................mmmmmmmm...", -"...................mmmmmmmmmmmm.", -".................mmmmmmmmmmmmmmm", -"...............mmmmmmmmmmmmmmmmm", -".............mmmmmmmmmmmmmmmmmmm", -"............mmmmmmmmmmmmmmmmmmmm", -"..............mmmmmmmmmmmmmmmmmm", -"................mmmmmmmmmmmmmmmm", -"..................mmmmmmmmmmmmmm", -"....................mmmmmmmmmmmm", -"......................mmmmmmmmmm", -"...............mm.......mmmmmmmm", -"...............mmmm.......mmmmmm", -"...............mmmmmm.......mmmm", -"...............mm.mmmmm.......mm", -"...............mm...mmmmm.......", -"...............mm.....mmmmm.....", -"...............mm.......mmmmm...", -"...............mm.........mmmmm.", -"...............mm...........mmmm", -"...............mm.............mm", -"...............mm...............", -"...............mm...............", -"...............mm...............", -"...............mm...............", -"...............mm...............", -"...............mm..............m", -"...............mm............mmm", -"...............mm..........mmmmm", -"...............mm........mmmmm..", -"...............mm........mmmm...", +".......................mmmm.....................................", +".....................mmmmmmmm...................................", +"...................mmmmmmmmmmmm.................................", +".................mmmmmmmmmmmmmmmm...............................", +"...............mmmmmmmmmmmmmmmmmmmm.............................", +".............mmmmmmmmmmmmmmmmmmmmmmmm...........................", +"............mmmmmmmmmmmmmmmmmmmmmmmmmmm...................mmmmmm", +"..............mmmmmmmmmmmmmmmmmmmmmmmmmmm............mmmmmmmmmmm", +"................mmmmmmmmmmmmmmmmmmmmmmmmmmm......mmmmmmmmmmmmmmm", +"..................mmmmmmmmmmmmmmmmmmmmmmmmmmm.mmmmmmmmmmmmmmmmmm", +"....................mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", +"......................mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", +"...............mm.......mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", +"...............mmmm.......mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmddddd", +"...............mmmmmm.......mmmmmmmmmmmmmmmmmmmmmmmmmmddddddbbbb", +"...............mm.mmmmm.......mmmmmmmmmmmmmmmmmmmdddddbbbbbbbbbb", +"...............mm...mmmmm.......mmmmmmmmmmmmmmmddddbbbbbbbbbbbdd", +"...............mm.....mmmmm.......mmmmmmmmmmddddbbbbbbbbdddddddd", +"...............mm.......mmmmm.....mmmmmmmmdddbbbbbbbdddddddddddd", +"...............mm.........mmmmm..mmmmmmmmddbbbbbbddddddddddddddd", +"...............mm...........mmmmmmmmmmmddbbbbbbddddddddddddddddd", +"...............mm.............mmmmmmmmddbbbbdddddddddddddddddddd", +"...............mm...............mmmmmdbbbbbddddddddddddddddddddd", +"...............mm................mmmdbbbbddddddddddddddddddddddd", +"...............mm................mmdbbbbdddddddddddddddddddddddd", +"...............mm.................mdbbbddddddddddddddddddddddddd", +"...............mm................mdbbbdddddddddddddddddddddddddd", +"...............mm..............mmdbbbddddddddddddddddddddddddddd", +"...............mm............mmmmbbbbddddddddddddddddddddddddddd", +"...............mm..........mmmmmmbbbbbbbdddddddddddddddddddddddb", +"...............mm........mmmmm...bbdbbbbbbbbbdddddddddddddddbbbb", +"...............mm........mmmm....bbbbbbbbbbbbbbbbbbdddddddbbbbdd", +"...............mm........mmmmmm.bbbdddbbbbbbbbbbbbbbbbddbbbbdddb", +"...............mm........mmmmmmmbbbdddddddddddddddddbbdbbbbddbbb", +"...............mm........mm..mmmbbdddddddddddddddddddddbbbddbbbb", +"...............mm........mm....mbbdddddddddddddddddddddbbdddbbbd", +"...............mm........mm.....bbdddddddddddddddddddddbbdddbbdd", +"...............mm........mm.....bbbdddddddddddddbbbbbbdbbbddbbbb", +"...............mm........mm.....bbbdddddddbbbbbbbbbbbbdbbbbdbbbb", +"...............mm........mm......bb.bbbbbbbbbbbbbbbb....bbbbmmbb", +"...............mm........mm......bbbbbbbbbbbbbbb.......dddbbbbbm", +"...............mm........mmm.....bbb.bbbbbbbbmmmm....ddddddbbbbb", +"...............mm........mmmmm....bbb.bbb.....mmmmmddddddddddddb", +"...............mm..........mmmmm...bbb..........mddddddddddddddd", +"...............mm............mmmmm..bbb........ddddddddddddddddd", +"...............mmm.............mmmmmbbbb.....ddddddddddddddddddd", +"...............mmmmm.............mmmmbbbbb.ddddddddddddddddddddd", +".................mmmmm.............mmmmbbbbddddddddddddddddddddd", +"...................mmmmm.............mmmbbbbdddddddddddddddddddd", +".....................mmmmm.............mmmbbbbdddddddddddddddddd", +".......................mmmmm.............mmbbbbbdddddddddddddddd", +".........................mmmmm.............mmmbbbbbddddddddddddd", +"...........................mmmmm.............mmmbbbbbbbbdddddddd", +".............................mmmmm.............mmmmmbbbbbbbbbbbb", +"...............................mmmmm.............mmmmmm..bbbbbbb", +".................................mmmmm.............mmmmm........", +"...................................mmmmm.............mmmmmm.....", +".....................................mmmmm.............mmmmmm...", +".......................................mmmmm.............mmmmmm.", +".........................................mmmmm.............mmmmm", +"...........................................mmmmm...dd........mmm", +".............................................mmmmm.dddd........m", +"...............................................mmmmdddddd.......", +".................................................mmdddddddd.....", }; diff --git a/ext/src/mcde/programs/icons/IrixDisk.m.pm b/ext/src/mcde/programs/icons/IrixDisk.m.pm index a661c59a98..55ab07dc22 100644 --- a/ext/src/mcde/programs/icons/IrixDisk.m.pm +++ b/ext/src/mcde/programs/icons/IrixDisk.m.pm @@ -1,7 +1,7 @@ /* XPM */ /* MCDE: IrixDisk.m.pm, from the IRIX Foundation icon (fti2xpm.py) */ static char *IrixDisk_m_pm[] = { -"32 32 8 1 0 0", +"64 64 8 1 0 0", "k c #000000", "w c #ffffff", "d c #202020", @@ -10,36 +10,68 @@ static char *IrixDisk_m_pm[] = { "b c #3f3f7f", "B c #707080", ". c None", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", +".......................dddd.....................................", +".....................dddddddd...................................", +"...................dddddddddddd.................................", +".................dddddddddddddddd...............................", +"...............dddddddddddddddddddd.............................", +".............dddddddddddddddddddddddd...........................", +"............ddddddddddddddddddddddddddd.........................", +"..............ddddddddddddddddddddddddddd.......................", +"................ddddddddddddddddddddddddddd.....................", +"..................ddddddddddddddddddddddddddd...................", +"....................ddddddddddddddddddddddddddd.................", +"......................ddddddddddddddddddddddddddd...............", +"...............mm.......ddddddddddddddddddddddddddd.............", +"...............mmmm.......ddddddddddddddddddddddddddd...........", +"...............mmmmmm.......ddddddddddddddddddddddddddd.........", +"...............mm.mmmmm.......ddddddddddddddddddddddddddd.......", +"...............mm...mmmmm.......ddddddddddddddddddddddddddd.....", +"...............mm.....mmmmm.......ddddddddddddddddddddddddddd...", +"...............mm.......mmmmm.......ddddddddddddddddddddddddddd.", +"...............mm.........mmmmm.......dddddddddddddddddddddddddd", +"...............mm...........mmmmm.......dddddddddddddddddddddddd", +"...............mm.............mmmmm.......dddddddddddddddddddddd", +"...............mm...............mmmmm.......dddddddddddddddddddd", +"...............mm.................mmmmm.......dddddddddddddddddd", +"...............mm...................mmmmm.......dddddddddddddddd", +"...............mm.....................mmmmm.......dddddddddddddd", +"...............mm.......................mmmmm.......dddddddddddd", +"...............mm.........................mmmmm.......dddddddddd", +"...............mm...........................mmmmm.......dddddddd", +"...............mm.............................mmmmm.......dddddd", +"...............mmm..............................mmmmm.......dddd", +"...............mmmmm..............................mmmmm.......dd", +"...............mmmmmmm..............................mmmmm.......", +"...............mm..mmmmm..............................mmmmm.....", +"...............mm....mmmmm..............................mmmmm...", +"...............mm......ddmmm..............................mmmmm.", +"...............mm......ddddmmm..............................mmmm", +"...............mm......ddddddmmm..............................mm", +"...............mmm.....ddddddddmmm..............................", +"...............mmmmm...dd..dddddmmmm............................", +"...............mmmmmmm.dd.....dd.mmmmm..........................", +"...............mm..mmmmdddd...dd.bbmmmmm........................", +"...............mm....mmmddddd.dd.bbbbmmmmm......................", +"...............mm......mmddddddd.bbbbbbmmmmm....................", +"...............mm........mmmdddd.bb.bbbb.mmmmm..................", +"...............mmm.........mmmddmbbbb.bb...mmmmm................", +"...............mmmmm.........mmmmbbbbbbb.....mmmmm..............", +".................mmmmm.........mmmmbbbbb.......mmmmm............", +"...................mmmmm.........mmmmbbb.........mmmmm..........", +".....................mmmmm.........mmmmmm..........mmmmm........", +".......................mmmmm.........mmmmmm..........mmmmm......", +".........................mmmmm.........mmmmmm..........mmmmm....", +"...........................mmmmm.........mmmmmm..........mmmmm..", +".............................mmmmm.........mmmmmm..........mmmmm", +"...............................mmmmm.........mmmmmm..........mmm", +".................................mmmmm.........mmmmmm..........m", +"...................................mmmmm.........mmmmmm.........", +".....................................mmmmm.........mmmmmm.......", +".......................................mmmmm.........mmmmmm.....", +".........................................mmmmm..........mmmmm...", +"...........................................mmmmm..........mmmmm.", +".............................................mmmmm..........mmmm", +"...............................................mmmmm..........mm", +".................................................mmmmm..........", }; diff --git a/ext/src/mcde/programs/icons/IrixFloppy.m.pm b/ext/src/mcde/programs/icons/IrixFloppy.m.pm index 9aa4650d17..e8999953ca 100644 --- a/ext/src/mcde/programs/icons/IrixFloppy.m.pm +++ b/ext/src/mcde/programs/icons/IrixFloppy.m.pm @@ -1,7 +1,7 @@ /* XPM */ /* MCDE: IrixFloppy.m.pm, from the IRIX Foundation icon (fti2xpm.py) */ static char *IrixFloppy_m_pm[] = { -"32 32 8 1 0 0", +"64 64 8 1 0 0", "k c #000000", "w c #ffffff", "d c #202020", @@ -10,36 +10,68 @@ static char *IrixFloppy_m_pm[] = { "b c #3f3f7f", "B c #707080", ". c None", -"........................mmm.....", -"......................mmmmmmm...", -"....................mmmmmmmmmmm.", -"..................mmmmmmmmmmmmmm", -"................mmmmmmmmmmmmmmmm", -"..............mmmmmmmmmmmmmmmmmm", -"............mmmmmmmmmmmmmmmmmmmm", -"............mmmmmmmmmmmmmmmmmmmm", -"..............mmmmmmmmmmmmmmmmmm", -"................mmmmmmmmmmmmmmmm", -"..................mmmmmmmmmmmmmm", -"....................mmmmmmmmmmmm", -"......................mmmmmmmmmm", -".................mm.....mmmmmmmm", -".................mmmm.....mmmmmm", -".................mmmmmm.....mmmm", -".................mm.mmmmm.....mm", -".................mm...mmmmm.....", -".................mm.....mmmmm...", -".................mm.......mmmmm.", -".................mm.........mmmm", -".................mm...........mm", -".................mm.............", -".................mm.............", -".................mm.............", -".................mm.............", -".................mm.............", -".................mm.............", -".................mm.............", -".................mm.............", -".................mm...........dd", -".................mm...bbb...dddd", +"........................mmm.....................................", +"......................mmmmmmm.................................bb", +"....................mmmmmmmmmmm.............................bbbb", +"..................mmmmmmmmmmmmmmm.........................bbbbbb", +"................mmmmmmmmmmmmmmmmmmm.....................bbbbbbbb", +"..............mmmmmmmmmmmmmmmmmmmmmmm.................bbbbbbbbbb", +"............mmmmmmmmmmmmmmmmmmmmmmmmmmm.............bbbbbbbbbbbb", +"............mmmmmmmmmmmmmmmmmmmmmmmmmmmmm.........bbbbbbbbbbbbbb", +"..............mmmmmmmmmmmmmmmmmmmmmmmmmmmmm.....bbbbbbbbbbbbbbbb", +"................mmmmmmmmmmmmmmmmmmmmmmmmmmmmm.bbbbbbbbbbbbbbbbbb", +"..................mmmmmmmmmmmmmmmmmmmmmmmmmmbbbbbbbbbbbbbbbbbbbb", +"....................mmmmmmmmmmmmmmmmmmmmmmbbbbbbbbbbbbbbbbbbbbbb", +"......................mmmmmmmmmmmmmmmmmmbbbbbbbbbbbbbbbbbbbbbbbb", +".................mm.....mmmmmmmmmmmmmmbbbbbbbbbbbbbbbbbbbbbbbbbb", +".................mmmm.....mmmmmmmmmmbbbbbbbbbbbbbbbbbbbbbbbbbbdd", +".................mmmmmm.....mmmmmmbbbbbbbbbbbbbbbbbbbbbbbbbbdddd", +".................mm.mmmmm.....mmmbbbbbbbbbbbbbbbbbbbbbbbbbdddddd", +".................mm...mmmmm.....mmmbbbbbbbbbbbbbbbbbbbbbdddddddd", +".................mm.....mmmmm.....mmmbbbbbbbbbbbbbbbbbdddddddddd", +".................mm.......mmmmm.....mmmbbbbbbbbbbbbbdddddddddddb", +".................mm.........mmmmm.....mmmbbbbbbbbbdddddddddddbbb", +".................mm...........mmmmm.....mmmbbbbbdddddddddddbbbbb", +".................mm.............mmmmm.....mmmbbddddddddddbbbbbbb", +".................mm...............mmmmm.....mddddddddddbbbbbbbbd", +".................mm.................mmmmm.ddddddddddbbbbbbbbbddd", +".................mm...................mmdddddddddddbbbbbbbbddddd", +".................mm...................ddddddddddd.mmmbbbbdddddbb", +".................mm.................ddddddddddd.....mmmdddddbbbb", +".................mm...............dddddddddddmmmm.....mdddddbbbb", +".................mm.............ddddddddddd...mmmmm.....mdddddbb", +".................mm...........ddddddddddd.......mmmmm.....mddddd", +".................mm...bbb...dddddddddddb..........mmmmm.....mddd", +".................mm...bbbbdddddddddddbbbbb..........mmmmm.....md", +".................mm...bbbbdddddddddbb..bbbbb..........mmmmm.....", +".................mm...bbmmddddddd..bb....bbbbb...ddddd..mmmmm...", +".................mm...bbmmdddddbb..bb......bbbbddddddddd..mmmmm.", +".................mm...bbbmddddbbbbbbb........dddddd..ddddd..mmmm", +".................mm...bbbbbdddddbbbbb......ddddddbbb...ddddd..mm", +".................mm.....bbbbbdddddbbbm...dddddd..bbbbb...ddddd..", +".................mm.......bbbbbddddddmmdddddd......bbbbbdddddddd", +".................mm.........bbbbbdddddddddd..........bdddddddddd", +".................mm...........bbbbbddddddmmm........dddddddddddd", +".................mm.............bbbbbddddddmmm....ddddddb.ddddd.", +".................mm...............bbbmmddddddmmmdddddd.bb.dddddb", +".................mm................bbmmmmddddddddddd...bddddddbd", +".................mm................bbmmmmmmdddddddmm..ddddddbddd", +".................mmm...............bbmmmmmmmmddddddmdddddd.ddddd", +".................mmmmm.............bbmmmmmmmmmmdddddddddbddddddb", +"...................mmmmm...........bbbbmmmmmmmmmmdddddmddddddbbb", +".....................mmmmm..........bbbbbmmmmmmmmmmddddddddbb...", +".......................mmmmm..........bbbbbmmmmmmmmmmdddddbbbbb.", +".........................mmmmm..........bbbbbmmmmmmmmmmdddddbbbb", +"...........................mmmmm..........bbbbbmmmmmmmbbbddddddd", +".............................mmmmm..........bbbbbmmmbbbbbbbddddd", +"...............................mmmmm..........bbbbbbbbbbbbbbbmmm", +".................................mmmmm..........bbbbbmmbb.bbbbbm", +"...................................mmmmm..........bbbbbbb...bbbb", +".....................................mmmmm..........bbbbb.....bb", +".......................................mmmmm..........bbb.......", +".........................................mmmmm..................", +"...........................................mmmmm................", +".............................................mmmmm..............", +"...............................................mmmmm............", +".................................................mmmmm..........", }; diff --git a/ext/src/mcde/programs/icons/IrixNet.m.pm b/ext/src/mcde/programs/icons/IrixNet.m.pm index c08f4785ec..18c6ba022f 100644 --- a/ext/src/mcde/programs/icons/IrixNet.m.pm +++ b/ext/src/mcde/programs/icons/IrixNet.m.pm @@ -1,7 +1,7 @@ /* XPM */ /* MCDE: IrixNet.m.pm, from the IRIX Foundation icon (fti2xpm.py) */ static char *IrixNet_m_pm[] = { -"32 32 8 1 0 0", +"64 64 8 1 0 0", "k c #000000", "w c #ffffff", "d c #202020", @@ -10,36 +10,68 @@ static char *IrixNet_m_pm[] = { "b c #3f3f7f", "B c #707080", ". c None", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"................................", -"mm..............................", -"mmmm............................", -"mmmmmm..........................", -"mmmmmmmm........................", -"mmmmmmmmmm......................", -"mmmmmmmmmmm.....................", -".mmmmmmmmmmmm...................", -"...mmmmmmmmmmm..................", -".....mmmmmmmmm..................", -".......mmmmmmm..................", -".........mmmmm..................", -"........mmmmmm..................", -"......mmmmmmmm..................", -".....mmmmmmmmm..................", -"....mmmmmmmmm...................", -"...mmmmmmmmm....................", -"...mmmmmmmm.....................", -"...mmmmm........................", -"...mmmmmmm......................", -"...mmmmmmmm.....................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"mm..............................................................", +"mmmm............................................................", +"mmmmmm..........................................................", +"mmmmmmmm........................................................", +"mmmmmmmmmm......................................................", +"mmmmmmmmmmm.....................................................", +".mmmmmmmmmmmm...................................................", +"...mmmmmmmmmmm..................................................", +".....mmmmmmmmm..................................................", +".......mmmmmmm..................................................", +".........mmmmm..................................................", +"........mmmmmm..................................................", +"......mmmmmmmm..................................................", +".....mmmmmmmmm..................................................", +"....mmmmmmmmm...................................................", +"...mmmmmmmmm....................................................", +"...mmmmmmmm.....................................................", +"...mmmmm........................................................", +"...mmmmmmm......................................................", +"...mmmmmmmm.....................................................", +"....mmmmmmmmm...................................................", +".....mmmmmmmmmm.................................................", +"......mmmmmmmmmmm...............................................", +".......mmmmmmmmmmmm.............................................", +".........mmmmmmmmmmm............................................", +"...........mmmmmmmmm............................................", +".............mmmmmmm............................................", +"...............mmmmm............................................", +".................mmm............................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", +"................................................................", }; diff --git a/ext/src/mcde/programs/icons/IrixTape.m.pm b/ext/src/mcde/programs/icons/IrixTape.m.pm index 837db00f4a..1739fad348 100644 --- a/ext/src/mcde/programs/icons/IrixTape.m.pm +++ b/ext/src/mcde/programs/icons/IrixTape.m.pm @@ -1,7 +1,7 @@ /* XPM */ /* MCDE: IrixTape.m.pm, from the IRIX Foundation icon (fti2xpm.py) */ static char *IrixTape_m_pm[] = { -"32 32 8 1 0 0", +"64 64 8 1 0 0", "k c #000000", "w c #ffffff", "d c #202020", @@ -10,36 +10,68 @@ static char *IrixTape_m_pm[] = { "b c #3f3f7f", "B c #707080", ". c None", -".......................mmmm.....", -".....................mmmmmmmm...", -"...................mmmmmmmmmmmm.", -".................mmmmmmmmmmmmmmm", -"...............mmmmmmmmmmmmmmmmm", -".............mmmmmmmmmmmmmmmmmmm", -"............mmmmmmmmmmmmmmmmmmmm", -"..............mmmmmmmmmmmmmmmmmm", -"................mmmmmmmmmmmmmmmm", -"..................mmmmmmmmmmmmmm", -"....................mmmmmmmmmmmm", -"......................mmmmmmmmmm", -"...............mm.......mmmmmmmm", -"...............mmmm.......mmmmmm", -"...............mmmmmm.......mmmm", -"...............mm.mmmmm.......mm", -"...............mm...mmmmm.......", -"...............mm.....mmmmm.....", -"...............mmmm.....mmmmm...", -"...............mmmmmm.....mmmmm.", -"...............mm.mmmmm.....mmmm", -"...............mm...mmmmm.....mm", -"...............mmm....mmmmm.....", -"...............mmmmm....mmmmm...", -"...............mmmmmmm....mmmmm.", -"...............mm.mmmmmm....mmmm", -"...............mm...mmmmmm....mm", -"...............mm.....mmmmmm....", -"...............mmmm.....mmmmmm..", -"...............mmmmmm.....mmmmmm", -"...............mm.mmmmm.....mmmm", -"...............mm...mmmmm.....mm", +".......................mmmm.....................................", +".....................mmmmmmmm...................................", +"...................mmmmmmmmmmmm........................m........", +".................mmmmmmmmmmmmmmmm....................mmmmm......", +"...............mmmmmmmmmmmmmmmmmmmm................mmmmmmmmm....", +".............mmmmmmmmmmmmmmmmmmmmmmmm............mmmmmmmmmmmmm..", +"............mmmmmmmmmmmmmmmmmmmmmmmmmmm........mmmmmmmmmmmmmmmmm", +"..............mmmmmmmmmmmmmmmmmmmmmmmmmmm....mmmmmmmmmmmmmmmmmmm", +"................mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", +"..................mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", +"....................mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", +"......................mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", +"...............mm.......mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", +"...............mmmm.......mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", +"...............mmmmmm.......mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", +"...............mm.mmmmm.......mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", +"...............mm...mmmmm.......mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", +"...............mm.....mmmmm.......mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", +"...............mmmm.....mmmmm.......mmmmmmmmmmmmmmmmmmmmmmmmmmmm", +"...............mmmmmm.....mmmmm.......mmmmmmmmmmmmmmmmmmmmmmmmmm", +"...............mm.mmmmm.....mmmmm.......mmmmmmmmmmmmmmmmmmmmmmmm", +"...............mm...mmmmm.....mmmmm.......mmmmmmmmmmmmmmmmmmmmmm", +"...............mmm....mmmmm.....mmmmm.......mmmmmmmmmmmmmmmmmmmm", +"...............mmmmm....mmmmm.....mmmmm.......mmmmmmmmmmmmmmmmmm", +"...............mmmmmmm....mmmmm.....mmmmm.......mmddmmmmmmmmmmmm", +"...............mm.mmmmmm....mmmmm.....mmmmm.....ddddmmmmmmmmmmmm", +"...............mm...mmmmmm....mmmmm.....mmmmm.ddddddmmmmmmmmmmmm", +"...............mm.....mmmmmm....mmmmm.....mmbbbdddddmmmmmmmmmmmm", +"...............mmmm.....mmmmmm....mmmmm...bbbbbdddddmm..mmmmmmmm", +"...............mmmmmm.....mmmmmm....mmmmbbbbbbbdddmmmm....mmmmmm", +"...............mm.mmmmm.....mmmmmm....bbbbbb.bbdmmmmmm......mmmm", +"...............mm...mmmmm.....mmmmmmbbbbbbmmmbbmmmmmmmm.......mm", +"...............mm.....mmmmm.....mmbbbbbb..mmbbbmmm..mmmmm.......", +"...............mm.......mmmmm...bbbbbbmm..bbbbbmm...mmmmmmm.....", +"...............mm.........mmmmbbbbb.mmmmbbbbbbmmmmmmmmmmmmmmm...", +"...............mm...........mmbbbb....bbbbbb....mmmmmmmmmmmmmmm.", +"...............mm....mmm...mmmbbmmm.bbbbbbmmmmmmmmmmmmmmmmmmmmmm", +"...............mm....mmmmm.mmmbbmmbbbbbb..mmmmmmdddddmmmmmmmmmmm", +"...............mm....mmmmmmmm.bbbbbbbddd..mmmmddddddddddmmmmmmmm", +"...............mm....mm.mmmmmmbbbbbbdddddmmmmddddmmmddddddmmmmmm", +"...............mm....mm...mmmmmm...dd.dddddm.ddddmmmmmddddddmmmm", +"...............mm....mm....mmmmmmm.ddmmmddddm.ddddddmmmmddddddmm", +"...............mm....mm....mm.mmmmmdddmm.dddddm.ddddddmmmmdddddd", +"...............mm....mm....mm...mmmdddd....dddddm.ddddddmmmmdddd", +"...............mm....mm....mm.mmmmdddddm.....ddddmm.ddddddmmmmdd", +"...............mm....mm....mmmmmddddddmmmm....dddddmm.ddddddmmmm", +"...............mm....mmm...mmmmddddd..mmmmmm....ddddmmm.ddddddmm", +"...............mm....mmmmm.mmmmddddd....mmmmmm...dddddmmm.dddddd", +"...............mmmm...mmmmmm.mmmmddddd....mmmmmm...dddddmmm.dddd", +"................mmmmm...mmmmmm.mmmmddddd....mmmmmm...ddddmmmm.dd", +"..................mmmmm...mmmmmm.mmmmddddd....mmmmmm..dddddmmmm.", +"....................mmmmm...mmmmmm.mmmmddddd....mmmmmm..dddddmmm", +"......................mmmmm...mmmmmm.mmmmddddd....mmmmmm.dddddmm", +"........................mmmmm...mmmmmm.mmmmddddd....mmmmmm.dddd.", +"..........................mmmmm...mmmmmm.mmmmddddd....mmmmmmdddd", +"............................mmmmm...mmmmmm.mmmmddddd....mmmmmmdd", +"..............................mmmmm...mmmmmm.mmmmddddd....mmmmmd", +"................................mmmmm...mmmmmm.mmmmddddd....mmmm", +"..................................mmmmm...mmmmmm.mmmmddddd....mm", +"....................................mmmmm...mmmmmm.mmmdddddd....", +"......................................mmmmm...mmmmmm.mmmmddddd..", +"........................................mmmmm...mmmmmm.mmmmddddd", +"..........................................mmmmm...mmmmmm.mmmmddd", +"............................................mmmmm...mmmmmm.mmmmd", }; diff --git a/ext/src/mcde/programs/localized/de_DE.UTF-8/msg/dtphoto.msg b/ext/src/mcde/programs/localized/de_DE.UTF-8/msg/dtphoto.msg index 929cfcbb62..65e1489e24 100644 --- a/ext/src/mcde/programs/localized/de_DE.UTF-8/msg/dtphoto.msg +++ b/ext/src/mcde/programs/localized/de_DE.UTF-8/msg/dtphoto.msg @@ -8,3 +8,5 @@ $set 1 4 Das Bild konnte nicht geƶffnet werden. 5 Das Bild konnte nicht gespeichert werden. 6 Werkzeugoptionen +7 Nichts konnte platziert werden. +8 Das Bild konnte nicht exportiert werden.