diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/GridText.c | 12 | ||||
-rw-r--r-- | src/HTAlert.c | 22 | ||||
-rw-r--r-- | src/HTFWriter.c | 4 | ||||
-rw-r--r-- | src/HTML.c | 27 | ||||
-rw-r--r-- | src/HTML.h | 4 | ||||
-rw-r--r-- | src/LYCgi.c | 21 | ||||
-rw-r--r-- | src/LYCookie.c | 16 | ||||
-rw-r--r-- | src/LYCurses.c | 27 | ||||
-rw-r--r-- | src/LYCurses.h | 6 | ||||
-rw-r--r-- | src/LYForms.c | 10 | ||||
-rw-r--r-- | src/LYGetFile.c | 13 | ||||
-rw-r--r-- | src/LYKeymap.c | 12 | ||||
-rw-r--r-- | src/LYMail.c | 9 | ||||
-rw-r--r-- | src/LYMain.c | 37 | ||||
-rw-r--r-- | src/LYStrings.c | 32 | ||||
-rw-r--r-- | src/LYUtils.c | 22 | ||||
-rw-r--r-- | src/parsdate.c | 328 | ||||
-rw-r--r-- | src/parsdate.y | 8 |
18 files changed, 343 insertions, 267 deletions
diff --git a/src/GridText.c b/src/GridText.c index a1cf0bb0..3c86ee69 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -1,5 +1,5 @@ /* - * $LynxId: GridText.c,v 1.191 2010/09/22 10:53:56 tom Exp $ + * $LynxId: GridText.c,v 1.194 2010/09/23 09:32:45 tom Exp $ * * Character grid hypertext object * =============================== @@ -806,8 +806,10 @@ static void LYAddHiText(TextAnchor *a, { HiliteInfo *have = a->lites.hl_info; unsigned need = (unsigned) (a->lites.hl_len - 1); - unsigned want = (unsigned) (a->lites.hl_len += 1) * (unsigned) sizeof(HiliteInfo); + unsigned want; + a->lites.hl_len = (short) (a->lites.hl_len + 1); + want = (unsigned) (a->lites.hl_len) * (unsigned) sizeof(HiliteInfo); if (have != NULL) { have = (HiliteInfo *) realloc(have, want); } else { @@ -10926,7 +10928,7 @@ int HText_SubmitForm(FormInfo * submit_item, DocInfo *doc, char *link_name, * Use the multipart MIME format. Later we will ensure it does not * occur within the content. */ - Boundary = "xnyLAaB03X"; + StrAllocCopy(Boundary, "xnyLAaB03X"); } /* @@ -13930,7 +13932,7 @@ static void move_to_glyph(int YP, * next actual normal character is handled. - kw */ data = hightext; - len = strlen(hightext); + len = (int) strlen(hightext); end_of_data = hightext + len; last_i = i + len; XP_next += linkvlen; @@ -14345,7 +14347,7 @@ void LYMoveToLink(int cur, } else { /* This should not happen. */ move_to_glyph(links[cur].ly, links[cur].lx, XP_draw_min, - "", 0, links[cur].lx, + "", 0, (unsigned) links[cur].lx, target, hightext, flags, utf_flag); } } diff --git a/src/HTAlert.c b/src/HTAlert.c index ce237e54..12416ec7 100644 --- a/src/HTAlert.c +++ b/src/HTAlert.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTAlert.c,v 1.86 2009/11/21 16:32:23 tom Exp $ + * $LynxId: HTAlert.c,v 1.89 2010/09/23 10:43:48 tom Exp $ * * Displaying messages and getting input for Lynx Browser * ========================================================== @@ -40,7 +40,7 @@ #ifdef HAVE_NAPMS #define LYSleep(n) napms(n) #else -#define LYSleep(n) sleep(n) +#define LYSleep(n) sleep((unsigned)n) #endif /* Issue a message about a problem. HTAlert() @@ -180,7 +180,7 @@ static const char *sprint_bytes(char *s, off_t n, const char *was_units) if (n >= 10 * kb_units) { sprintf(s, "%" PRI_off_t, CAST_off_t(n / kb_units)); } else if (n > 999) { /* Avoid switching between 1016b/s and 1K/s */ - sprintf(s, "%.2g", ((double) n) / kb_units); + sprintf(s, "%.2g", ((double) n) / (double) kb_units); } else { sprintf(s, "%" PRI_off_t, CAST_off_t(n)); u = HTProgressUnits(rateBYTES); @@ -226,7 +226,7 @@ void HTReadProgress(off_t bytes, off_t total) static double first, last, last_active; gettimeofday(&tv, (struct timezone *) 0); - now = tv.tv_sec + tv.tv_usec / 1000000.; + now = (double) tv.tv_sec + (double) tv.tv_usec / 1000000.; #else #if defined(HAVE_FTIME) && defined(HAVE_SYS_TIMEB_H) static double now, first, last, last_active; @@ -254,8 +254,10 @@ void HTReadProgress(off_t bytes, off_t total) /* 1 sec delay for transfer_rate calculation without g-t-o-d */ if ((bytes > 0) && (now > first)) { - if (transfer_rate <= 0) /* the very first time */ - transfer_rate = (off_t) ((bytes) / (now - first)); /* bytes/sec */ + if (transfer_rate <= 0) { /* the very first time */ + transfer_rate = (off_t) ((double) (bytes) / (now - first)); + /* bytes/sec */ + } total_last = total; /* @@ -281,7 +283,7 @@ void HTReadProgress(off_t bytes, off_t total) if (bytes_last != bytes) last_active = now; bytes_last = bytes; - transfer_rate = (off_t) (bytes / (now - first)); /* more accurate value */ + transfer_rate = (off_t) ((double) bytes / (now - first)); /* more accurate value */ } if (total > 0) @@ -300,8 +302,8 @@ void HTReadProgress(off_t bytes, off_t total) HTSprintf0(&line, gettext("Read %s of data"), bytesp); if (total > 0) { - float percent = bytes / (float) total; - int meter = (LYcolLimit * percent) - 5; + float percent = (float) bytes / (float) total; + int meter = (int) (((float) LYcolLimit * percent) - 5); CTRACE((tfp, "rateBAR: bytes: %" PRI_off_t ", total: " "%" PRI_off_t "\n", bytes, total)); @@ -909,7 +911,7 @@ BOOL HTConfirmCookie(domain_entry * de, const char *server, * (O/N/Toujours/Jamais) - French */ char *p = gettext("Y/N/A/V"); /* placeholder for comment */ - char *s = "YNAV\007\003"; /* see ADVANCED_COOKIE_CONFIRMATION */ + const char *s = "YNAV\007\003"; /* see ADVANCED_COOKIE_CONFIRMATION */ if (strchr(s, ch) == 0 && isalpha(ch) diff --git a/src/HTFWriter.c b/src/HTFWriter.c index 918da49f..2398c882 100644 --- a/src/HTFWriter.c +++ b/src/HTFWriter.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTFWriter.c,v 1.93 2010/04/30 00:01:09 tom Exp $ + * $LynxId: HTFWriter.c,v 1.94 2010/09/22 22:53:58 tom Exp $ * * FILE WRITER HTFWrite.h * =========== @@ -91,7 +91,7 @@ struct _HTStream { /* Error handling * ------------------ */ -static void HTFWriter_error(HTStream *me, char *id) +static void HTFWriter_error(HTStream *me, const char *id) { char buf[200]; diff --git a/src/HTML.c b/src/HTML.c index ce31d60a..3981724e 100644 --- a/src/HTML.c +++ b/src/HTML.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTML.c,v 1.139 2010/06/18 00:05:37 tom Exp $ + * $LynxId: HTML.c,v 1.141 2010/09/23 09:18:00 tom Exp $ * * Structured stream to Rich hypertext converter * ============================================ @@ -725,7 +725,7 @@ void HTML_write(HTStructured * me, const char *s, int l) #ifdef USE_COLOR_STYLE static char *Style_className = 0; static char *Style_className_end = 0; -static unsigned Style_className_len = 0; +static size_t Style_className_len = 0; static int hcode; #ifdef LY_FIND_LEAKS @@ -737,11 +737,11 @@ static void free_Style_className(void) static void addClassName(const char *prefix, const char *actual, - unsigned length) + size_t length) { - unsigned offset = strlen(prefix); - unsigned have = (unsigned) (Style_className_end - Style_className); - unsigned need = (offset + length + 1); + size_t offset = strlen(prefix); + size_t have = (unsigned) (Style_className_end - Style_className); + size_t need = (offset + length + 1); if ((have + need) >= Style_className_len) { Style_className_len += 1024 + 2 * (have + need); @@ -5567,7 +5567,7 @@ static int HTML_start_element(HTStructured * me, int element_number, #ifdef USE_JUSTIFY_ELTS if (wait_for_this_stacked_elt < 0 && HTML_dtd.tags[ElementNumber].can_justify == FALSE) - wait_for_this_stacked_elt = me->stack - me->sp + MAX_NESTING; + wait_for_this_stacked_elt = (int) (me->stack - me->sp) + MAX_NESTING; #endif } #ifdef USE_JUSTIFY_ELTS @@ -5613,6 +5613,8 @@ static int HTML_start_element(HTStructured * me, int element_number, static int HTML_end_element(HTStructured * me, int element_number, char **include) { + static char empty[1]; + int i = 0; int status = HT_OK; char *temp = NULL, *cp = NULL; @@ -6886,7 +6888,7 @@ static int HTML_end_element(HTStructured * me, int element_number, } else { FREE(temp); } - data = ""; + data = empty; } /* * Display at least the requested number of text lines and/or blank @@ -6915,7 +6917,7 @@ static int HTML_end_element(HTStructured * me, int element_number, data = (cp + 1); } else { StrAllocCopy(temp, data); - data = ""; + data = empty; } } else { FREE(temp); @@ -6948,7 +6950,7 @@ static int HTML_end_element(HTStructured * me, int element_number, data = (cp + 1); } else if (*data != '\0') { StrAllocCopy(temp, data); - data = ""; + data = empty; } else { FREE(temp); } @@ -7946,9 +7948,10 @@ static void CacheThru_write(HTStream *me, const char *str, int l) { if (me->status == HT_OK && l != 0) { if (me->fp) { - fwrite(str, 1, (unsigned) l, me->fp); - if (ferror(me->fp)) + if (fwrite(str, 1, (size_t) l, me->fp) < (size_t) l + || ferror(me->fp)) { me->status = HT_ERROR; + } } else if (me->chunk) { me->last_chunk = HTChunkPutb2(me->last_chunk, str, l); if (me->last_chunk == NULL || me->last_chunk->allocated == 0) diff --git a/src/HTML.h b/src/HTML.h index 695ed9f2..27c15d07 100644 --- a/src/HTML.h +++ b/src/HTML.h @@ -124,8 +124,8 @@ extern "C" { BOOL HiddenValue; int lastraw; - char *comment_start; /* for literate programming */ - char *comment_end; + const char *comment_start; /* for literate programming */ + const char *comment_end; HTTag *current_tag; BOOL style_change; diff --git a/src/LYCgi.c b/src/LYCgi.c index 9409ae80..11911267 100644 --- a/src/LYCgi.c +++ b/src/LYCgi.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYCgi.c,v 1.58 2010/06/17 10:44:09 tom Exp $ + * $LynxId: LYCgi.c,v 1.59 2010/09/22 22:51:03 tom Exp $ * Lynx CGI support LYCgi.c * ================ * @@ -434,12 +434,14 @@ static int LYLoadCGI(const char *arg, CTRACE_FLUSH(tfp); if ((pid = fork()) > 0) { /* The good, */ - int chars, total_chars; + ssize_t chars; + int total_chars; close(fd2[1]); if (anAnchor->post_data) { - int written, remaining, total_written = 0; + ssize_t written; + int remaining, total_written = 0; close(fd1[0]); @@ -469,9 +471,9 @@ static int LYLoadCGI(const char *arg, break; } CTRACE((tfp, "LYNXCGI: Wrote %d bytes of POST data.\n", - written)); - total_written += written; - remaining -= written; + (int) written)); + total_written += (int) written; + remaining -= (int) written; if (remaining == 0) break; } @@ -496,9 +498,10 @@ static int LYLoadCGI(const char *arg, PERROR("read() of CGI output failed"); break; } - HTReadProgress(total_chars += chars, 0); - CTRACE((tfp, "LYNXCGI: Rx: %.*s\n", chars, buf)); - (*target->isa->put_block) (target, buf, chars); + total_chars += (int) chars; + HTReadProgress(total_chars, 0); + CTRACE((tfp, "LYNXCGI: Rx: %.*s\n", (int) chars, buf)); + (*target->isa->put_block) (target, buf, (int) chars); } if (chars < 0 && total_chars == 0) { diff --git a/src/LYCookie.c b/src/LYCookie.c index 75b5b240..04f18313 100644 --- a/src/LYCookie.c +++ b/src/LYCookie.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYCookie.c,v 1.101 2010/06/18 10:54:16 tom Exp $ + * $LynxId: LYCookie.c,v 1.102 2010/09/22 21:24:00 tom Exp $ * * Lynx Cookie Support LYCookie.c * =================== @@ -134,7 +134,7 @@ static void MemAllocCopy(char **dest, temp = typecallocn(char, (unsigned)(end - start) + 1); if (temp == NULL) outofmem(__FILE__, "MemAllocCopy"); - LYstrncpy(temp, start, (end - start)); + LYstrncpy(temp, start, (int) (end - start)); HTSACopy(dest, temp); FREE(temp); } @@ -848,7 +848,7 @@ static char *alloc_attr_value(const char *value_start, char *value = NULL; if (value_start && value_end >= value_start) { - int value_len = (value_end - value_start); + int value_len = (int) (value_end - value_start); if (value_len > max_cookies_buffer) { value_len = max_cookies_buffer; @@ -881,7 +881,7 @@ static unsigned parse_attribute(unsigned flags, BOOLEAN known_attr = NO; int url_type; - flags &= ~FLAGS_KNOWN_ATTR; + flags &= (unsigned) (~FLAGS_KNOWN_ATTR); if (is_attr("secure", 6)) { if (value == NULL) { known_attr = YES; @@ -1040,7 +1040,7 @@ static unsigned parse_attribute(unsigned flags, * Don't process a repeat version. - FM */ cur_cookie->version < 1) { - int temp = strtol(value, NULL, 10); + int temp = (int) strtol(value, NULL, 10); if (errno != -ERANGE) { cur_cookie->version = temp; @@ -1053,7 +1053,7 @@ static unsigned parse_attribute(unsigned flags, * Don't process a repeat max-age. - FM */ !(flags & FLAGS_MAXAGE_ATTR)) { - int temp = strtol(value, NULL, 10); + int temp = (int) strtol(value, NULL, 10); cur_cookie->flags |= COOKIE_FLAG_EXPIRES_SET; if (errno == -ERANGE) { @@ -1326,7 +1326,7 @@ static void LYProcessSetCookies(const char *SetCookie, cur_cookie, &cookie_len, attr_start, - (attr_end - attr_start), + (int) (attr_end - attr_start), value, address, hostname, @@ -1620,7 +1620,7 @@ static void LYProcessSetCookies(const char *SetCookie, cur_cookie, &cookie_len, attr_start, - (attr_end - attr_start), + (int) (attr_end - attr_start), value, address, hostname, diff --git a/src/LYCurses.c b/src/LYCurses.c index 2ca21098..347f8749 100644 --- a/src/LYCurses.c +++ b/src/LYCurses.c @@ -1,4 +1,4 @@ -/* $LynxId: LYCurses.c,v 1.152 2010/09/22 10:51:44 tom Exp $ */ +/* $LynxId: LYCurses.c,v 1.153 2010/09/23 09:06:19 tom Exp $ */ #include <HTUtils.h> #include <HTAlert.h> @@ -136,13 +136,13 @@ void VTHome(void) void LYaddAttr(int a) { Current_Attr |= a; - SLsmg_set_color(Current_Attr & ~Masked_Attr); + SLsmg_set_color((SLsmg_Color_Type) (Current_Attr & ~Masked_Attr)); } void LYsubAttr(int a) { Current_Attr &= ~a; - SLsmg_set_color(Current_Attr & ~Masked_Attr); + SLsmg_set_color((SLsmg_Color_Type) (Current_Attr & ~Masked_Attr)); } static void lynx_setup_attrs(void) @@ -161,7 +161,7 @@ static void lynx_setup_attrs(void) int n; for (n = 1; n <= 7; n++) - SLtt_set_mono(n, NULL, (monoattr[n] & ~Masked_Attr)); + SLtt_set_mono(n, NULL, (SLtt_Char_Type) (monoattr[n] & ~Masked_Attr)); } void lynx_setup_colors(void) @@ -298,7 +298,10 @@ static char *attr_to_string(int code) void LYbox(WINDOW * win, BOOLEAN formfield GCC_UNUSED) { #ifdef USE_SLANG - SLsmg_draw_box(win->top_y, win->left_x, win->height, win->width + 4); + SLsmg_draw_box(win->top_y, + win->left_x, + (unsigned) win->height, + (unsigned) win->width + 4); #else #ifdef VMS /* @@ -869,11 +872,11 @@ void LYnoVideo(int a) CTRACE((tfp, "LYnoVideo(%d)\n", a)); #ifdef USE_SLANG if (a & 1) - Masked_Attr |= SLTT_BOLD_MASK; + Masked_Attr |= (int) SLTT_BOLD_MASK; if (a & 2) - Masked_Attr |= SLTT_REV_MASK; + Masked_Attr |= (int) SLTT_REV_MASK; if (a & 4) - Masked_Attr |= SLTT_ULINE_MASK; + Masked_Attr |= (int) SLTT_ULINE_MASK; lynx_setup_attrs(); #else #ifdef USE_COLOR_TABLE @@ -991,7 +994,7 @@ void start_curses(void) size_change(0); #if (defined(VMS) || defined(REAL_UNIX_SYSTEM)) && !defined(__CYGWIN__) - if ((Masked_Attr & SLTT_ULINE_MASK) == 0) { + if ((Masked_Attr & (int) SLTT_ULINE_MASK) == 0) { SLtt_add_color_attribute(4, SLTT_ULINE_MASK); SLtt_add_color_attribute(5, SLTT_ULINE_MASK); } @@ -1811,7 +1814,11 @@ WINDOW *LYstartPopup(int *top_y, *width = LYcolLimit - 5; } - SLsmg_fill_region(*top_y, *left_x - 1, *height, *width + 4, ' '); + SLsmg_fill_region(*top_y, + *left_x - 1, + (unsigned) *height, + (unsigned) *width + 4, + ' '); form_window = &fake_window; form_window->top_y = *top_y; form_window->left_x = *left_x; diff --git a/src/LYCurses.h b/src/LYCurses.h index 178b0d4d..c1377994 100644 --- a/src/LYCurses.h +++ b/src/LYCurses.h @@ -1,4 +1,4 @@ -/* $LynxId: LYCurses.h,v 1.83 2009/11/27 12:58:31 tom Exp $ */ +/* $LynxId: LYCurses.h,v 1.84 2010/09/23 09:06:29 tom Exp $ */ #ifndef LYCURSES_H #define LYCURSES_H @@ -49,7 +49,11 @@ #endif /* FALSE */ #ifdef USE_SLANG +#define ENABLE_SLFUTURE_CONST 1 #include <slang.h> +#ifndef SLFUTURE_CONST +#define SLFUTURE_CONST /* nothing */ +#endif typedef unsigned long chtype; #undef WINDOW diff --git a/src/LYForms.c b/src/LYForms.c index 76d5a582..17396902 100644 --- a/src/LYForms.c +++ b/src/LYForms.c @@ -1,4 +1,4 @@ -/* $LynxId: LYForms.c,v 1.84 2010/04/30 00:00:55 tom Exp $ */ +/* $LynxId: LYForms.c,v 1.85 2010/09/22 23:01:41 tom Exp $ */ #include <HTUtils.h> #include <HTCJK.h> #include <HTTP.h> @@ -396,7 +396,7 @@ static int form_getstr(int cur, max_length = ((form->maxlength > 0 && form->maxlength < sizeof(MyEdit.buffer)) ? form->maxlength - : (sizeof(MyEdit.buffer) - 1)); + : (unsigned) (sizeof(MyEdit.buffer) - 1)); if (strlen(form->value) > max_length) { /* * We can't fit the entire value into the editing buffer, so enter as @@ -606,10 +606,10 @@ static int form_getstr(int cur, while (e1 < e) { if (*e1 < ' ') { /* Stop here? */ if (e1 > s) - LYEditInsert(&MyEdit, s, e1 - s, -1, TRUE); + LYEditInsert(&MyEdit, s, (int) (e1 - s), -1, TRUE); s = e1; if (*e1 == '\t') { /* Replace by space */ - LYEditInsert(&MyEdit, (unsigned char *) " ", 1, + LYEditInsert(&MyEdit, (unsigned const char *) " ", 1, -1, TRUE); s = ++e1; } else @@ -618,7 +618,7 @@ static int form_getstr(int cur, ++e1; } if (e1 > s) - LYEditInsert(&MyEdit, s, e1 - s, -1, TRUE); + LYEditInsert(&MyEdit, s, (int) (e1 - s), -1, TRUE); while (e1 < e && *e1 == '\r') e1++; if (e1 + 1 < e && *e1 == '\n') diff --git a/src/LYGetFile.c b/src/LYGetFile.c index 751dd189..c0a35f95 100644 --- a/src/LYGetFile.c +++ b/src/LYGetFile.c @@ -1,4 +1,4 @@ -/* $LynxId: LYGetFile.c,v 1.80 2010/04/29 09:16:49 tom Exp $ */ +/* $LynxId: LYGetFile.c,v 1.81 2010/09/23 09:37:14 tom Exp $ */ #include <HTUtils.h> #include <HTTP.h> #include <HTAnchor.h> /* Anchor class */ @@ -1321,6 +1321,7 @@ void add_trusted(char *str, struct trust *tp; char *path; char *src = str; + const char *after_tab; int Type = type; static BOOLEAN first = TRUE; @@ -1334,10 +1335,12 @@ void add_trusted(char *str, } path = strchr(src, '\t'); - if (path) + if (path) { *path++ = '\0'; - else - path = ""; + after_tab = path; + } else { + after_tab = ""; + } tp = (struct trust *) malloc(sizeof(*tp)); if (tp == NULL) @@ -1349,7 +1352,7 @@ void add_trusted(char *str, tp->path = NULL; tp->type = Type; StrAllocCopy(tp->src, src); - StrAllocCopy(tp->path, path); + StrAllocCopy(tp->path, after_tab); if (Type == EXEC_PATH) { if (trusted_exec == &trusted_exec_default) tp->next = NULL; diff --git a/src/LYKeymap.c b/src/LYKeymap.c index c0c4205a..505297df 100644 --- a/src/LYKeymap.c +++ b/src/LYKeymap.c @@ -1,4 +1,4 @@ -/* $LynxId: LYKeymap.c,v 1.69 2009/11/21 17:05:33 Bela.Lubkin Exp $ */ +/* $LynxId: LYKeymap.c,v 1.70 2010/09/22 23:02:55 tom Exp $ */ #include <HTUtils.h> #include <LYUtils.h> #include <LYGlobalDefs.h> @@ -1127,8 +1127,8 @@ Kcmd *LYKeycodeToKcmd(LYKeymapCode code) */ Kcmd *LYStringToKcmd(const char *name) { - unsigned need = strlen(name); - unsigned j; + size_t need = strlen(name); + size_t j; BOOL exact = FALSE; Kcmd *result = 0; Kcmd *maybe = 0; @@ -1203,13 +1203,13 @@ int LYStringToKeycode(char *src) } else if (len > 2 && !strncasecomp(src, "0x", 2)) { char *dst = 0; - key = strtol(src, &dst, 0); + key = (int) strtol(src, &dst, 0); if (non_empty(dst)) key = -1; } else if (len > 6 && !strncasecomp(src, "key-", 4)) { char *dst = 0; - key = strtol(src + 4, &dst, 0); + key = (int) strtol(src + 4, &dst, 0); if (isEmpty(dst)) key = -1; } @@ -1264,7 +1264,7 @@ static char *pretty_html(int c) *dst++ = (char) c; } } - adj -= (dst - buf) - PRETTY_LEN; + adj -= (int) (dst - buf) - PRETTY_LEN; while (adj-- > 0) *dst++ = ' '; *dst = 0; diff --git a/src/LYMail.c b/src/LYMail.c index 9cfc25ed..40eec44c 100644 --- a/src/LYMail.c +++ b/src/LYMail.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMail.c,v 1.73 2010/04/29 09:16:49 tom Exp $ + * $LynxId: LYMail.c,v 1.74 2010/09/23 09:15:58 tom Exp $ */ #include <HTUtils.h> #include <HTParse.h> @@ -1127,7 +1127,7 @@ void reply_by_mail(char *mail_address, #endif char buf[4096]; /* 512 */ char *header = NULL; - int n; + size_t nbytes; #endif /* USE_VMS_MAILER */ CTRACE((tfp, "reply_by_mail(\"%s\", \"%s\", \"%s\", \"%s\")\n", @@ -1671,8 +1671,9 @@ void reply_by_mail(char *mail_address, #else fputs(header, fp); #endif - while ((n = (int) fread(buf, 1, sizeof(buf), fd)) != 0) { - fwrite(buf, 1, (size_t) n, fp); + while ((nbytes = fread(buf, 1, sizeof(buf), fd)) != 0) { + if (fwrite(buf, 1, (size_t) nbytes, fp) < nbytes) + break; } #if CAN_PIPE_TO_MAILER pclose(fp); diff --git a/src/LYMain.c b/src/LYMain.c index abb23ce5..337dff17 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMain.c,v 1.216 2010/09/19 18:20:35 tom Exp $ + * $LynxId: LYMain.c,v 1.218 2010/09/23 09:52:26 tom Exp $ */ #include <HTUtils.h> #include <HTTP.h> @@ -940,7 +940,7 @@ static void SetLocale(void) /* Set the text message domain. */ #if defined(HAVE_LIBINTL_H) || defined(HAVE_LIBGETTEXT_H) { - char *cp; + const char *cp; if ((cp = LYGetEnv("LYNX_LOCALEDIR")) == 0) cp = LOCALEDIR; @@ -959,6 +959,7 @@ int main(int argc, int i; /* indexing variable */ int status = 0; /* exit status */ char *temp = NULL; + const char *ccp; char *cp; FILE *fp; struct stat dir_info; @@ -1033,8 +1034,8 @@ int main(int argc, signal(SIGQUIT, cleanup_sig); atexit(reset_break); - if (((cp = LYGetEnv("SHELL")) != NULL) - && (strstr(LYPathLeaf(cp), "sh") != NULL)) + if (((ccp = LYGetEnv("SHELL")) != NULL) + && (strstr(LYPathLeaf(ccp), "sh") != NULL)) dj_is_bash = TRUE; #endif /* __DJGPP__ */ @@ -1077,11 +1078,11 @@ int main(int argc, /* * Set up the TRACE log path, and logging if appropriate. - FM */ - if ((cp = LYGetEnv("LYNX_TRACE_FILE")) == 0) - cp = FNAME_LYNX_TRACE; + if ((ccp = LYGetEnv("LYNX_TRACE_FILE")) == 0) + ccp = FNAME_LYNX_TRACE; LYTraceLogPath = typeMallocn(char, LY_MAXPATH); - LYAddPathToHome(LYTraceLogPath, LY_MAXPATH, cp); + LYAddPathToHome(LYTraceLogPath, LY_MAXPATH, ccp); /* * Act on -version, -trace and -trace-mask NOW. @@ -1179,17 +1180,17 @@ int main(int argc, */ #endif /* VMS */ - if ((cp = LYGetEnv("LYNX_TEMP_SPACE")) != NULL) - StrAllocCopy(lynx_temp_space, cp); + if ((ccp = LYGetEnv("LYNX_TEMP_SPACE")) != NULL) + StrAllocCopy(lynx_temp_space, ccp); #if defined (UNIX) || defined (__DJGPP__) - else if ((cp = LYGetEnv("TMPDIR")) != NULL) - StrAllocCopy(lynx_temp_space, cp); + else if ((ccp = LYGetEnv("TMPDIR")) != NULL) + StrAllocCopy(lynx_temp_space, ccp); #endif #if defined (DOSPATH) || defined (__EMX__) - else if ((cp = LYGetEnv("TEMP")) != NULL) - StrAllocCopy(lynx_temp_space, cp); - else if ((cp = LYGetEnv("TMP")) != NULL) - StrAllocCopy(lynx_temp_space, cp); + else if ((ccp = LYGetEnv("TEMP")) != NULL) + StrAllocCopy(lynx_temp_space, ccp); + else if ((ccp = LYGetEnv("TMP")) != NULL) + StrAllocCopy(lynx_temp_space, ccp); #endif else #ifdef TEMP_SPACE @@ -3077,7 +3078,7 @@ G)oto's" }, } value = show_restriction(table[j].name); printf("%s%s (%s)", column ? ", " : " ", name, value); - column += 5 + strlen(name) + strlen(value); + column += (unsigned) (5 + strlen(name) + strlen(value)); if (column > 50) { column = 0; printf("\n"); @@ -4250,7 +4251,7 @@ static BOOL parse_arg(char **argv, } /* ignore option if it's not our turn */ - if ((p->type & mask) == 0) { + if (((unsigned) (p->type) & mask) == 0) { CTRACE((tfp, "...skip (mask %u/%d)\n", mask, p->type & 7)); return FALSE; } @@ -4296,7 +4297,7 @@ static BOOL parse_arg(char **argv, case INT_ARG: if ((q->int_value != 0) && (next_arg != 0)) - *(q->int_value) = strtol(next_arg, &temp_ptr, 0); + *(q->int_value) = (int) strtol(next_arg, &temp_ptr, 0); break; case TIME_ARG: diff --git a/src/LYStrings.c b/src/LYStrings.c index cf27f1dc..647ad4a2 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -1,4 +1,4 @@ -/* $LynxId: LYStrings.c,v 1.174 2010/09/22 10:52:38 tom Exp $ */ +/* $LynxId: LYStrings.c,v 1.175 2010/09/23 08:44:00 tom Exp $ */ #include <HTUtils.h> #include <HTCJK.h> #include <UCAux.h> @@ -829,7 +829,7 @@ static int sl_parse_mouse_event(int *x, int *y, int *button) /* "ESC [ M" has already been processed. There more characters are * expected: BUTTON X Y */ - *button = SLang_getkey(); + *button = (int) SLang_getkey(); switch (*button) { case 040: /* left button */ case 041: /* middle button */ @@ -842,14 +842,14 @@ static int sl_parse_mouse_event(int *x, int *y, int *button) return -1; } - *x = SLang_getkey(); + *x = (int) SLang_getkey(); if (*x == CH_ESC) /* Undo 7-bit replace for large x - kw */ - *x = SLang_getkey() + 64 - 33; + *x = (int) SLang_getkey() + 64 - 33; else *x -= 33; - *y = SLang_getkey(); + *y = (int) SLang_getkey(); if (*y == CH_ESC) /* Undo 7-bit replace for large y - kw */ - *y = SLang_getkey() + 64 - 33; + *y = (int) SLang_getkey() + 64 - 33; else *y -= 33; return 0; @@ -893,10 +893,14 @@ void ena_csi(BOOLEAN flag) #ifdef USE_SLANG #define define_key(string, code) \ - SLkm_define_keysym ((char*)(string), code, Keymap_List) + SLkm_define_keysym ((SLFUTURE_CONST char*)(string), \ + (unsigned) code, \ + Keymap_List) #if SLANG_VERSION < 20000 #define expand_substring(dst, first, last, final) \ - (SLexpand_escaped_string(dst, (char *)first, (char *)last), 1) + (SLexpand_escaped_string(dst, \ + (char *)first, \ + (char *)last), 1) static int SLang_get_error(void) { return SLang_Error; @@ -905,7 +909,10 @@ static int SLang_get_error(void) int LY_Slang_UTF8_Mode = 0; #define expand_substring(dst, first, last, final) \ - (SLexpand_escaped_string(dst, (char *)first, (char *)last, LY_Slang_UTF8_Mode), 1) + (SLexpand_escaped_string(dst, \ + (char *)first, \ + (char *)last, \ + LY_Slang_UTF8_Mode), 1) #endif static SLKeyMap_List_Type *Keymap_List; @@ -1143,7 +1150,8 @@ static BOOLEAN unescape_string(char *src, char *dst, char *final) ok = TRUE; } } else if (*src == DQUOTE) { - ok = expand_substring(dst, src + 1, src + strlen(src) - 1, final); + if (expand_substring(dst, src + 1, src + strlen(src) - 1, final)) + ok = TRUE; (void) final; } return ok; @@ -1684,7 +1692,7 @@ static int LYgetch_for(int code) return (current_sl_modifier ? 0 : DO_NOTHING); } - keysym = key->f.keysym; + keysym = (int) key->f.keysym; #if defined (USE_MOUSE) if (keysym == MOUSE_KEYSYM) @@ -4033,7 +4041,7 @@ static void draw_option(WINDOW * win, int entry, LYaddstr(Cnum); if (reversed) SLsmg_set_color(2); - SLsmg_write_nstring((char *) value, win->width); + SLsmg_write_nstring((SLFUTURE_CONST char *) value, (unsigned) win->width); if (reversed) SLsmg_set_color(0); #else diff --git a/src/LYUtils.c b/src/LYUtils.c index 81032d3a..8fe8fbc2 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYUtils.c,v 1.196 2010/09/22 10:50:17 tom Exp $ + * $LynxId: LYUtils.c,v 1.198 2010/09/23 09:39:14 tom Exp $ */ #include <HTUtils.h> #include <HTTCP.h> @@ -379,8 +379,11 @@ void LYAddHilite(int cur, { HiliteList *list = &(links[cur].list); HiliteInfo *have = list->hl_info; - unsigned need = (unsigned) (list->hl_len - 1); - unsigned want = (unsigned) (list->hl_len += 1); + size_t need = (unsigned) (list->hl_len - 1); + size_t want; + + list->hl_len = (short) (list->hl_len + 1); + want = (size_t) list->hl_len; if (have != NULL) { have = typeRealloc(HiliteInfo, have, want); @@ -1450,10 +1453,10 @@ void statusline(const char *text) */ remove_most_blanks(text_buff); #ifdef WIDEC_CURSES - len = strlen(text_buff); + len = (int) strlen(text_buff); if (len >= (int) (sizeof(buffer) - 1)) len = (int) (sizeof(buffer) - 1); - strncpy(buffer, text_buff, len)[len] = '\0'; + strncpy(buffer, text_buff, (size_t) len)[len] = '\0'; /* FIXME: a binary search might be faster */ while (len > 0 && LYstrExtent(buffer, len, len) > max_length) buffer[--len] = '\0'; @@ -1620,7 +1623,7 @@ int LYReopenInput(void) if ((fd = fileno(stdin)) == 0 && !isatty(fd) && LYConsoleInputFD(FALSE) == fd) { - char *term_name = NULL; + const char *term_name = NULL; int new_fd = -1; #ifdef HAVE_TTYNAME @@ -3447,8 +3450,11 @@ static int fmt_tempname(char *result, */ counter = MAX_TEMPNAME; if (names_used < MAX_TEMPNAME) { - counter = (unsigned) (((float) MAX_TEMPNAME * lynx_rand()) / - LYNX_RAND_MAX + 1); + long get_rand = lynx_rand(); + long max_rand = LYNX_RAND_MAX; + + counter = (unsigned) (((float) MAX_TEMPNAME * (float) get_rand) / + (float) max_rand + 1); /* * Avoid reusing a temporary name, since there are places in the code * which can refer to a temporary filename even after it has been diff --git a/src/parsdate.c b/src/parsdate.c index 97578ef3..ce271e33 100644 --- a/src/parsdate.c +++ b/src/parsdate.c @@ -2,38 +2,23 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; #endif -#include <stdlib.h> -#include <string.h> - #define YYBYACC 1 #define YYMAJOR 1 #define YYMINOR 9 -#define YYPATCH 20081224 +#define YYPATCH 20100610 #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) -/* 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) -#endif -#else -#define YYPARSE_DECL() yyparse(void) -#endif /* YYPARSE_PARAM */ +#define YYPREFIX "yy" -extern int YYPARSE_DECL(); +#define YYPURE 0 -static int yygrowstack(void); -#define YYPREFIX "yy" #line 2 "./parsdate.y" /* - * $LynxId: parsdate.c,v 1.8 2009/01/01 22:12:42 tom Exp $ + * $LynxId: parsdate.c,v 1.9 2010/09/22 21:18:46 tom Exp $ * * This module is adapted and extended from tin, to use for LYmktime(). * @@ -169,7 +154,31 @@ typedef union { time_t Number; enum _MERIDIAN Meridian; } YYSTYPE; -#line 172 "y.tab.c" +#line 157 "y.tab.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) +# endif +#else +# define YYPARSE_DECL() yyparse(void) +#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() +#endif + +extern int YYPARSE_DECL(); +extern int YYLEX_DECL(); + #define tDAY 257 #define tDAYZONE 258 #define tMERIDIAN 259 @@ -346,10 +355,6 @@ static const char *yyrule[] = { }; #endif -#if YYDEBUG -#include <stdio.h> -#endif - /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH @@ -367,18 +372,22 @@ static const char *yyrule[] = { int yydebug; int yynerrs; + +typedef struct { + unsigned stacksize; + short *s_base; + short *s_mark; + short *s_last; + YYSTYPE *l_base; + YYSTYPE *l_mark; +} YYSTACKDATA; int yyerrflag; int yychar; -short *yyssp; -YYSTYPE *yyvsp; YYSTYPE yyval; YYSTYPE yylval; /* variables for the parser stack */ -static short *yyss; -static short *yysslim; -static YYSTYPE *yyvs; -static unsigned yystacksize; +static YYSTACKDATA yystack; #line 358 "./parsdate.y" /* @@ -862,7 +871,7 @@ date_lex(void) } *p = '\0'; yyInput--; - return LookupWord(buff, p - buff); + return LookupWord(buff, (int) (p - buff)); } return *yyInput++; @@ -986,44 +995,65 @@ parsedate( * from the error return value. (Alternately could set errno on error.) */ return Start == -1 ? 0 : Start; } -#line 989 "y.tab.c" +#line 998 "y.tab.c" + +#if YYDEBUG +#include <stdio.h> /* needed for printf */ +#endif + +#include <stdlib.h> /* needed for malloc, etc */ +#include <string.h> /* needed for memset */ + /* allocate initial stack or double stack size, up to YYMAXDEPTH */ -static int yygrowstack(void) +static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; short *newss; YYSTYPE *newvs; - if ((newsize = yystacksize) == 0) + if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return -1; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; - i = yyssp - yyss; - newss = (yyss != 0) - ? (short *)realloc(yyss, newsize * sizeof(*newss)) + i = data->s_mark - data->s_base; + newss = (data->s_base != 0) + ? (short *)realloc(data->s_base, newsize * sizeof(*newss)) : (short *)malloc(newsize * sizeof(*newss)); if (newss == 0) return -1; - yyss = newss; - yyssp = newss + i; - newvs = (yyvs != 0) - ? (YYSTYPE *)realloc(yyvs, newsize * sizeof(*newvs)) + data->s_base = newss; + data->s_mark = newss + i; + + newvs = (data->l_base != 0) + ? (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)) : (YYSTYPE *)malloc(newsize * sizeof(*newvs)); if (newvs == 0) return -1; - yyvs = newvs; - yyvsp = newvs + i; - yystacksize = newsize; - yysslim = yyss + newsize - 1; + 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 @@ -1049,17 +1079,21 @@ YYPARSE_DECL() yychar = YYEMPTY; yystate = 0; - if (yyss == NULL && yygrowstack()) goto yyoverflow; - yyssp = yyss; - yyvsp = yyvs; +#if YYPURE + memset(&yystack, 0, sizeof(yystack)); +#endif + + if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; + yystack.s_mark = yystack.s_base; + yystack.l_mark = yystack.l_base; yystate = 0; - *yyssp = 0; + *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { - if ((yychar = yylex()) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = 0; #if YYDEBUG if (yydebug) { @@ -1079,13 +1113,13 @@ yyloop: printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yyssp >= yysslim && yygrowstack()) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) { goto yyoverflow; } yystate = yytable[yyn]; - *++yyssp = yytable[yyn]; - *++yyvsp = yylval; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; @@ -1111,21 +1145,21 @@ yyinrecovery: yyerrflag = 3; for (;;) { - if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && + 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, *yyssp, yytable[yyn]); + to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); #endif - if (yyssp >= yysslim && yygrowstack()) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) { goto yyoverflow; } yystate = yytable[yyn]; - *++yyssp = yytable[yyn]; - *++yyvsp = yylval; + *++yystack.s_mark = yytable[yyn]; + *++yystack.l_mark = yylval; goto yyloop; } else @@ -1133,11 +1167,11 @@ yyinrecovery: #if YYDEBUG if (yydebug) printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yyssp); + YYPREFIX, *yystack.s_mark); #endif - if (yyssp <= yyss) goto yyabort; - --yyssp; - --yyvsp; + if (yystack.s_mark <= yystack.s_base) goto yyabort; + --yystack.s_mark; + --yystack.l_mark; } } } @@ -1166,7 +1200,7 @@ yyreduce: #endif yym = yylen[yyn]; if (yym) - yyval = yyvsp[1-yym]; + yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); switch (yyn) @@ -1187,7 +1221,7 @@ case 4: #line 163 "./parsdate.y" { yyHaveTime++; - yyTimezone = yyvsp[0].Number; + yyTimezone = yystack.l_mark[0].Number; } break; case 5: @@ -1208,7 +1242,7 @@ case 7: { yyHaveDate++; yyHaveTime++; - yyTimezone = yyvsp[0].Number; + yyTimezone = yystack.l_mark[0].Number; } break; case 8: @@ -1220,33 +1254,33 @@ break; case 9: #line 184 "./parsdate.y" { - if (yyvsp[-1].Number < 100) { - yyHour = yyvsp[-1].Number; + if (yystack.l_mark[-1].Number < 100) { + yyHour = yystack.l_mark[-1].Number; yyMinutes = 0; } else { - yyHour = yyvsp[-1].Number / 100; - yyMinutes = yyvsp[-1].Number % 100; + yyHour = yystack.l_mark[-1].Number / 100; + yyMinutes = yystack.l_mark[-1].Number % 100; } yySeconds = 0; - yyMeridian = yyvsp[0].Meridian; + yyMeridian = yystack.l_mark[0].Meridian; } break; case 10: #line 196 "./parsdate.y" { - yyHour = yyvsp[-3].Number; - yyMinutes = yyvsp[-1].Number; + yyHour = yystack.l_mark[-3].Number; + yyMinutes = yystack.l_mark[-1].Number; yySeconds = 0; - yyMeridian = yyvsp[0].Meridian; + yyMeridian = yystack.l_mark[0].Meridian; } break; case 11: #line 202 "./parsdate.y" { - yyHour = yyvsp[-3].Number; - yyMinutes = yyvsp[-1].Number; - yyTimezone = yyvsp[0].Number; + yyHour = yystack.l_mark[-3].Number; + yyMinutes = yystack.l_mark[-1].Number; + yyTimezone = yystack.l_mark[0].Number; yyMeridian = MER24; yyDSTmode = DSToff; } @@ -1254,19 +1288,19 @@ break; case 12: #line 209 "./parsdate.y" { - yyHour = yyvsp[-5].Number; - yyMinutes = yyvsp[-3].Number; - yySeconds = yyvsp[-1].Number; - yyMeridian = yyvsp[0].Meridian; + yyHour = yystack.l_mark[-5].Number; + yyMinutes = yystack.l_mark[-3].Number; + yySeconds = yystack.l_mark[-1].Number; + yyMeridian = yystack.l_mark[0].Meridian; } break; case 13: #line 215 "./parsdate.y" { - yyHour = yyvsp[-5].Number; - yyMinutes = yyvsp[-3].Number; - yySeconds = yyvsp[-1].Number; - yyTimezone = yyvsp[0].Number; + yyHour = yystack.l_mark[-5].Number; + yyMinutes = yystack.l_mark[-3].Number; + yySeconds = yystack.l_mark[-1].Number; + yyTimezone = yystack.l_mark[0].Number; yyMeridian = MER24; yyDSTmode = DSToff; } @@ -1274,21 +1308,21 @@ break; case 14: #line 225 "./parsdate.y" { - yyval.Number = yyvsp[0].Number; + yyval.Number = yystack.l_mark[0].Number; yyDSTmode = DSToff; } break; case 15: #line 229 "./parsdate.y" { - yyval.Number = yyvsp[0].Number; + yyval.Number = yystack.l_mark[0].Number; yyDSTmode = DSTon; } break; case 16: #line 233 "./parsdate.y" { - yyTimezone = yyvsp[-1].Number; + yyTimezone = yystack.l_mark[-1].Number; yyDSTmode = DSTon; } break; @@ -1296,17 +1330,17 @@ case 17: #line 237 "./parsdate.y" { /* Only allow "GMT+300" and "GMT-0800" */ - if (yyvsp[-1].Number != 0) { + if (yystack.l_mark[-1].Number != 0) { YYABORT; } - yyval.Number = yyvsp[0].Number; + yyval.Number = yystack.l_mark[0].Number; yyDSTmode = DSToff; } break; case 18: #line 245 "./parsdate.y" { - yyval.Number = yyvsp[0].Number; + yyval.Number = yystack.l_mark[0].Number; yyDSTmode = DSToff; } break; @@ -1316,96 +1350,96 @@ case 19: int i; /* Unix and GMT and numeric timezones -- a little confusing. */ - if ((int)yyvsp[0].Number < 0) { + if ((int)yystack.l_mark[0].Number < 0) { /* Don't work with negative modulus. */ - yyvsp[0].Number = -(int)yyvsp[0].Number; - if (yyvsp[0].Number > 9999 || (i = yyvsp[0].Number % 100) >= 60) { + yystack.l_mark[0].Number = -(int)yystack.l_mark[0].Number; + if (yystack.l_mark[0].Number > 9999 || (i = (int) (yystack.l_mark[0].Number % 100)) >= 60) { YYABORT; } - yyval.Number = (yyvsp[0].Number / 100) * 60 + i; + yyval.Number = (yystack.l_mark[0].Number / 100) * 60 + i; } else { - if (yyvsp[0].Number > 9999 || (i = yyvsp[0].Number % 100) >= 60) { + if (yystack.l_mark[0].Number > 9999 || (i = (int) (yystack.l_mark[0].Number % 100)) >= 60) { YYABORT; } - yyval.Number = -((yyvsp[0].Number / 100) * 60 + i); + yyval.Number = -((yystack.l_mark[0].Number / 100) * 60 + i); } } break; case 20: #line 272 "./parsdate.y" { - yyMonth = yyvsp[-2].Number; - yyDay = yyvsp[0].Number; + yyMonth = yystack.l_mark[-2].Number; + yyDay = yystack.l_mark[0].Number; } break; case 21: #line 276 "./parsdate.y" { - if (yyvsp[-4].Number > 100) { - yyYear = yyvsp[-4].Number; - yyMonth = yyvsp[-2].Number; - yyDay = yyvsp[0].Number; + if (yystack.l_mark[-4].Number > 100) { + yyYear = yystack.l_mark[-4].Number; + yyMonth = yystack.l_mark[-2].Number; + yyDay = yystack.l_mark[0].Number; } else { - yyMonth = yyvsp[-4].Number; - yyDay = yyvsp[-2].Number; - yyYear = yyvsp[0].Number; + yyMonth = yystack.l_mark[-4].Number; + yyDay = yystack.l_mark[-2].Number; + yyYear = yystack.l_mark[0].Number; } } break; case 22: #line 288 "./parsdate.y" { - yyMonth = yyvsp[-1].Number; - yyDay = yyvsp[0].Number; + yyMonth = yystack.l_mark[-1].Number; + yyDay = yystack.l_mark[0].Number; } break; case 23: #line 292 "./parsdate.y" { - yyMonth = yyvsp[-3].Number; - yyDay = yyvsp[-2].Number; - yyYear = yyvsp[0].Number; + yyMonth = yystack.l_mark[-3].Number; + yyDay = yystack.l_mark[-2].Number; + yyYear = yystack.l_mark[0].Number; } break; case 24: #line 297 "./parsdate.y" { - yyDay = yyvsp[-1].Number; - yyMonth = yyvsp[0].Number; + yyDay = yystack.l_mark[-1].Number; + yyMonth = yystack.l_mark[0].Number; } break; case 25: #line 301 "./parsdate.y" { - yyDay = yyvsp[-2].Number; - yyMonth = yyvsp[-1].Number; - yyYear = yyvsp[0].Number; + yyDay = yystack.l_mark[-2].Number; + yyMonth = yystack.l_mark[-1].Number; + yyYear = yystack.l_mark[0].Number; } break; case 26: #line 306 "./parsdate.y" { - yyDay = yyvsp[-2].Number; - yyMonth = yyvsp[-1].Number; - yyYear = yyvsp[0].Number; + yyDay = yystack.l_mark[-2].Number; + yyMonth = yystack.l_mark[-1].Number; + yyYear = yystack.l_mark[0].Number; } break; case 27: #line 311 "./parsdate.y" { - yyDay = yyvsp[-3].Number; - yyMonth = yyvsp[-1].Number; - yyYear = -yyvsp[0].Number; + yyDay = yystack.l_mark[-3].Number; + yyMonth = yystack.l_mark[-1].Number; + yyYear = -yystack.l_mark[0].Number; } break; case 28: #line 316 "./parsdate.y" { - yyDay = yyvsp[-2].Number; - yyMonth = -yyvsp[-1].Number; - yyYear = -yyvsp[0].Number; + yyDay = yystack.l_mark[-2].Number; + yyMonth = -yystack.l_mark[-1].Number; + yyYear = -yystack.l_mark[0].Number; yyDSTmode = DSToff; /* assume midnight if no time given */ yyTimezone = 0; /* Lynx assumes GMT for this format */ } @@ -1413,36 +1447,36 @@ break; case 29: #line 325 "./parsdate.y" { - yyMonth = yyvsp[-7].Number; - yyDay = yyvsp[-6].Number; - yyYear = yyvsp[0].Number; - yyHour = yyvsp[-5].Number; - yyMinutes = yyvsp[-3].Number; - yySeconds = yyvsp[-1].Number; + yyMonth = yystack.l_mark[-7].Number; + yyDay = yystack.l_mark[-6].Number; + yyYear = yystack.l_mark[0].Number; + yyHour = yystack.l_mark[-5].Number; + yyMinutes = yystack.l_mark[-3].Number; + yySeconds = yystack.l_mark[-1].Number; } break; case 30: #line 335 "./parsdate.y" { - yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number; + yyRelSeconds += yystack.l_mark[-1].Number * yystack.l_mark[0].Number; } break; case 31: #line 338 "./parsdate.y" { - yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number; + yyRelSeconds += yystack.l_mark[-1].Number * yystack.l_mark[0].Number; } break; case 32: #line 341 "./parsdate.y" { - yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number; + yyRelMonth += yystack.l_mark[-1].Number * yystack.l_mark[0].Number; } break; case 33: #line 344 "./parsdate.y" { - yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number; + yyRelMonth += yystack.l_mark[-1].Number * yystack.l_mark[0].Number; } break; case 34: @@ -1454,14 +1488,14 @@ break; case 35: #line 352 "./parsdate.y" { - yyval.Meridian = yyvsp[0].Meridian; + yyval.Meridian = yystack.l_mark[0].Meridian; } break; -#line 1460 "y.tab.c" +#line 1494 "y.tab.c" } - yyssp -= yym; - yystate = *yyssp; - yyvsp -= yym; + yystack.s_mark -= yym; + yystate = *yystack.s_mark; + yystack.l_mark -= yym; yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { @@ -1471,11 +1505,11 @@ break; state %d\n", YYPREFIX, YYFINAL); #endif yystate = YYFINAL; - *++yyssp = YYFINAL; - *++yyvsp = yyval; + *++yystack.s_mark = YYFINAL; + *++yystack.l_mark = yyval; if (yychar < 0) { - if ((yychar = yylex()) < 0) yychar = 0; + if ((yychar = YYLEX) < 0) yychar = 0; #if YYDEBUG if (yydebug) { @@ -1498,22 +1532,24 @@ break; #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yyssp, yystate); +to state %d\n", YYPREFIX, *yystack.s_mark, yystate); #endif - if (yyssp >= yysslim && yygrowstack()) + if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) { goto yyoverflow; } - *++yyssp = (short) yystate; - *++yyvsp = yyval; + *++yystack.s_mark = (short) yystate; + *++yystack.l_mark = yyval; goto yyloop; yyoverflow: yyerror("yacc stack overflow"); yyabort: + yyfreestack(&yystack); return (1); yyaccept: + yyfreestack(&yystack); return (0); } diff --git a/src/parsdate.y b/src/parsdate.y index 3466fc65..6942d297 100644 --- a/src/parsdate.y +++ b/src/parsdate.y @@ -1,6 +1,6 @@ %{ /* - * $LynxId: parsdate.y,v 1.12 2009/01/01 22:12:25 tom Exp $ + * $LynxId: parsdate.y,v 1.13 2010/09/22 21:18:43 tom Exp $ * * This module is adapted and extended from tin, to use for LYmktime(). * @@ -255,13 +255,13 @@ numzone : tSNUMBER { if ((int)$1 < 0) { /* Don't work with negative modulus. */ $1 = -(int)$1; - if ($1 > 9999 || (i = $1 % 100) >= 60) { + if ($1 > 9999 || (i = (int) ($1 % 100)) >= 60) { YYABORT; } $$ = ($1 / 100) * 60 + i; } else { - if ($1 > 9999 || (i = $1 % 100) >= 60) { + if ($1 > 9999 || (i = (int) ($1 % 100)) >= 60) { YYABORT; } $$ = -(($1 / 100) * 60 + i); @@ -837,7 +837,7 @@ date_lex(void) } *p = '\0'; yyInput--; - return LookupWord(buff, p - buff); + return LookupWord(buff, (int) (p - buff)); } return *yyInput++; |