X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Fparse_entry.c;h=0e3a8bfad198a7f97dc3a17f63fa796d12ab4c9e;hp=fa1c38355c2c067d378f2fcbcc6c31c8ccc6fdb6;hb=d4d1d81ab6fc1ad681ff120d925099f947fefcf3;hpb=614f0d6711aad3f1a99c149cc533e74f8af3c444;ds=sidebyside diff --git a/ncurses/tinfo/parse_entry.c b/ncurses/tinfo/parse_entry.c index fa1c3835..0e3a8bfa 100644 --- a/ncurses/tinfo/parse_entry.c +++ b/ncurses/tinfo/parse_entry.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. * + * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -47,7 +47,7 @@ #include #include -MODULE_ID("$Id: parse_entry.c,v 1.73 2010/04/17 22:41:48 tom Exp $") +MODULE_ID("$Id: parse_entry.c,v 1.76 2011/07/27 01:14:47 tom Exp $") #ifdef LINT static short const parametrized[] = @@ -203,6 +203,8 @@ _nc_extend_names(ENTRY * entryp, char *name, int token_type) { bad_tc_usage = TRUE; \ _nc_warning("Legacy termcap allows only a trailing tc= clause"); } +#define MAX_NUMBER 0x7fff /* positive shorts only */ + NCURSES_EXPORT(int) _nc_parse_entry(struct entry *entryp, int literal, bool silent) { @@ -444,8 +446,12 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent) break; case NUMBER: - entryp->tterm.Numbers[entry_ptr->nte_index] = - (short) _nc_curr_token.tk_valnumber; + if (_nc_curr_token.tk_valnumber > MAX_NUMBER) { + entryp->tterm.Numbers[entry_ptr->nte_index] = MAX_NUMBER; + } else { + entryp->tterm.Numbers[entry_ptr->nte_index] = + (short) _nc_curr_token.tk_valnumber; + } break; case STRING: @@ -668,7 +674,7 @@ postprocess_termcap(TERMTYPE *tp, bool has_base) else if (PRESENT(backspace_if_not_bs)) cursor_left = backspace_if_not_bs; } - /* vi doesn't use "do", but it does seems to use nl (or '\n') instead */ + /* vi doesn't use "do", but it does seem to use nl (or '\n') instead */ if (WANTED(cursor_down)) { if (PRESENT(linefeed_if_not_lf)) cursor_down = linefeed_if_not_lf; @@ -773,7 +779,7 @@ postprocess_termcap(TERMTYPE *tp, bool has_base) * isn't from mytinfo... */ if (PRESENT(other_non_function_keys)) { - char *base = other_non_function_keys; + char *base; char *bp, *cp, *dp; struct name_table_entry const *from_ptr; struct name_table_entry const *to_ptr; @@ -841,7 +847,7 @@ postprocess_termcap(TERMTYPE *tp, bool has_base) } else *dp++ = *bp; } - *dp++ = '\0'; + *dp = '\0'; tp->Strings[to_ptr->nte_index] = _nc_save_str(buf2); }