diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/HTML.c | 5 | ||||
-rw-r--r-- | src/LYCgi.c | 76 | ||||
-rw-r--r-- | src/LYEdit.c | 92 | ||||
-rw-r--r-- | src/LYEditmap.c | 2 | ||||
-rw-r--r-- | src/LYLocal.c | 24 | ||||
-rw-r--r-- | src/LYMain.c | 4 | ||||
-rw-r--r-- | src/LYMainLoop.c | 4 | ||||
-rw-r--r-- | src/LYStrings.c | 80 | ||||
-rw-r--r-- | src/LYStrings.h | 4 |
9 files changed, 198 insertions, 93 deletions
diff --git a/src/HTML.c b/src/HTML.c index fa12456d..cd7dac93 100644 --- a/src/HTML.c +++ b/src/HTML.c @@ -1126,8 +1126,8 @@ PRIVATE void HTML_start_element ARGS6( if (present && present[HTML_LINK_CLASS] && value && *value[HTML_LINK_CLASS]!='\0') { - char tmp[1024]; - sprintf(tmp, "link.%s.%s.%s", value[HTML_LINK_CLASS], title, value[HTML_LINK_CLASS]); + char *tmp = 0; + HTSprintf0(&tmp, "link.%s.%s.%s", value[HTML_LINK_CLASS], title, value[HTML_LINK_CLASS]); CTRACE(tfp, "CSSTRIM:link=%s\n", tmp); HText_characterStyle(me->text, hash_code(tmp), 1); @@ -1136,6 +1136,7 @@ PRIVATE void HTML_start_element ARGS6( HTML_put_string(me, value[HTML_LINK_CLASS]); HTML_put_string(me, ")"); HText_characterStyle(me->text, hash_code(tmp), 0); + FREE(tmp); } else #endif diff --git a/src/LYCgi.c b/src/LYCgi.c index 4ad5f376..e939d308 100644 --- a/src/LYCgi.c +++ b/src/LYCgi.c @@ -59,8 +59,10 @@ PRIVATE char **env = NULL; /* Environment variables */ PRIVATE int envc_size = 0; /* Slots in environment array */ PRIVATE int envc = 0; /* Slots used so far */ #ifdef LYNXCGI_LINKS -PRIVATE char user_agent[64]; -PRIVATE char server_software[64]; +PRIVATE char *user_agent; +PRIVATE char *server_software; +PRIVATE char *accept_language; +PRIVATE char *post_len; #endif /* LYNXCGI_LINKS */ PRIVATE void add_environment_value PARAMS((char *env_value)); @@ -311,9 +313,12 @@ PRIVATE int LYLoadCGI ARGS4( sink, anAnchor); if (!target || target == NULL) { - sprintf(buf, CANNOT_CONVERT_I_TO_O, - HTAtom_name(format_in), HTAtom_name(format_out)); - HTAlert(buf); + char *tmp = 0; + HTSprintf0(&tmp, CANNOT_CONVERT_I_TO_O, + HTAtom_name(format_in), + HTAtom_name(format_out)); + HTAlert(tmp); + FREE(tmp); status = HT_NOT_LOADED; } else if (anAnchor->post_data && pipe(fd1) < 0) { @@ -341,11 +346,11 @@ PRIVATE int LYLoadCGI ARGS4( add_environment_value("REMOTE_HOST=localhost"); add_environment_value("REMOTE_ADDR=127.0.0.1"); - sprintf(user_agent, "HTTP_USER_AGENT=%s/%s libwww/%s", + HTSprintf0(&user_agent, "HTTP_USER_AGENT=%s/%s libwww/%s", LYNX_NAME, LYNX_VERSION, HTLibraryVersion); add_environment_value(user_agent); - sprintf(server_software, "SERVER_SOFTWARE=%s/%s", + HTSprintf0(&server_software, "SERVER_SOFTWARE=%s/%s", LYNX_NAME, LYNX_VERSION); add_environment_value(server_software); } @@ -423,10 +428,8 @@ PRIVATE int LYLoadCGI ARGS4( } else if (pid == 0) { /* The Bad, */ char **argv = NULL; - char post_len[32]; int argv_cnt = 3; /* name, one arg and terminator */ char **cur_argv = NULL; - char buf2[BUFSIZ]; /* Set up output pipe */ close(fd2[0]); @@ -434,10 +437,8 @@ PRIVATE int LYLoadCGI ARGS4( dup2(fd2[1], fileno(stderr)); close(fd2[1]); - sprintf(buf2, "HTTP_ACCEPT_LANGUAGE=%.*s", - (int)(sizeof(buf2) - 22), language); - buf2[(sizeof(buf2) - 1)] = '\0'; - add_environment_value(buf2); + HTSprintf0(&accept_language, "HTTP_ACCEPT_LANGUAGE=%s", language); + add_environment_value(accept_language); if (pref_charset) { cp = NULL; @@ -463,7 +464,7 @@ PRIVATE int LYLoadCGI ARGS4( add_environment_value("REQUEST_METHOD=POST"); - sprintf(post_len, "CONTENT_LENGTH=%d", + HTSprintf0(&post_len, "CONTENT_LENGTH=%d", strlen(anAnchor->post_data)); add_environment_value(post_len); } else { @@ -582,38 +583,39 @@ PRIVATE int LYLoadCGI ARGS4( FREE(pgm); FREE(orig_pgm); #else /* VMS */ - HTStream *target; - char buf[256]; + HTStream *target; + char *buf = 0; - target = HTStreamStack(WWW_HTML, - format_out, - sink, anAnchor); + target = HTStreamStack(WWW_HTML, + format_out, + sink, anAnchor); - sprintf(buf, "<head>\n<title>%s</title>\n</head>\n<body>\n", gettext("Good Advice")); - (*target->isa->put_block)(target, buf, strlen(buf)); + HTSprintf0(&buf, "<head>\n<title>%s</title>\n</head>\n<body>\n", gettext("Good Advice")); + (*target->isa->put_block)(target, buf, strlen(buf)); - sprintf(buf, "<h1>%s</h1>\n", gettext("Good Advice")); - (*target->isa->put_block)(target, buf, strlen(buf)); + HTSprintf0(&buf, "<h1>%s</h1>\n", gettext("Good Advice")); + (*target->isa->put_block)(target, buf, strlen(buf)); - sprintf(buf, "%s <a\n", gettext("An excellent http server for VMS is available via")); - (*target->isa->put_block)(target, buf, strlen(buf)); + HTSprintf0(&buf, "%s <a\n", gettext("An excellent http server for VMS is available via")); + (*target->isa->put_block)(target, buf, strlen(buf)); - sprintf(buf, - "href=\"http://kcgl1.eng.ohio-state.edu/www/doc/serverinfo.html\"\n"); - (*target->isa->put_block)(target, buf, strlen(buf)); + HTSprintf0(&buf, + "href=\"http://kcgl1.eng.ohio-state.edu/www/doc/serverinfo.html\"\n"); + (*target->isa->put_block)(target, buf, strlen(buf)); - sprintf(buf, ">%s</a>.\n", gettext("this link")); - (*target->isa->put_block)(target, buf, strlen(buf)); + HTSprintf0(&buf, ">%s</a>.\n", gettext("this link")); + (*target->isa->put_block)(target, buf, strlen(buf)); - sprintf(buf, "<p>%s\n", - gettext("It provides state of the art CGI script support.\n")); - (*target->isa->put_block)(target, buf, strlen(buf)); + HTSprintf0(&buf, "<p>%s\n", + gettext("It provides state of the art CGI script support.\n")); + (*target->isa->put_block)(target, buf, strlen(buf)); - sprintf(buf,"</body>\n"); - (*target->isa->put_block)(target, buf, strlen(buf)); + HTSprintf0(&buf,"</body>\n"); + (*target->isa->put_block)(target, buf, strlen(buf)); - (*target->isa->_free)(target); - status = HT_LOADED; + (*target->isa->_free)(target); + FREE(buf); + status = HT_LOADED; #endif /* VMS */ #else /* LYNXCGI_LINKS */ HTUserMsg(CGI_NOT_COMPILED); diff --git a/src/LYEdit.c b/src/LYEdit.c index b05a5575..772e4fa3 100644 --- a/src/LYEdit.c +++ b/src/LYEdit.c @@ -15,6 +15,17 @@ #include <LYLeaks.h> +PRIVATE BOOLEAN editor_can_position NOARGS +{ +#ifdef VMS + return (strstr(editor, "sedt") || strstr(editor, "SEDT")); +#else + return (strstr(editor, "emacs") || strstr(editor, "vi") || + strstr(editor, "pico") || strstr(editor, "jove") || + strstr(editor, "jed")); +#endif +} + /* * In edit mode invoke either emacs, vi, pico, jove, jed sedt or the * default editor to display and edit the current file. @@ -27,9 +38,13 @@ PUBLIC int edit_current_file ARGS3( int, cur, int, lineno) { - char command[512]; + int result = FALSE; + int params = 1; + char *format = "%s %s"; + char *command = NULL; char *filename = NULL; char *colon, *number_sign; + char position[80]; FILE *fp; /* @@ -63,13 +78,16 @@ PUBLIC int edit_current_file ARGS3( filename = HTParse(newfile, "", PARSE_PATH+PARSE_PUNCTUATION); HTUnEscape(filename); #if defined (DOSPATH) || defined (__EMX__) - if (strlen(filename)>1) filename++; + if (strlen(filename) > 1) { /* FIXME: why do we need to do this? */ + int n; + for (n = 0; (filename[n] = filename[n+1]) != 0; n++) + ; + } #endif if ((fp = fopen(HTSYS_name(filename), "r")) == NULL) { HTAlert(COULD_NOT_ACCESS_FILE); - FREE(filename); - goto failure; + goto done; } #if !defined (VMS) && !defined (DOSPATH) && !defined (__EMX__) } @@ -83,7 +101,7 @@ PUBLIC int edit_current_file ARGS3( if ((fp = fopen(HTSYS_name(filename), "a")) == NULL) { HTUserMsg(NOAUTH_TO_EDIT_FILE); - goto failure; + goto done; } fclose(fp); #endif /* VMS || CANT_EDIT_UNWRITABLE_FILES */ @@ -98,36 +116,36 @@ PUBLIC int edit_current_file ARGS3( /* * Set up the command for the editor. - FM */ + *position = 0; +#ifdef VMS + lineno--; +#endif + lineno += (nlinks ? links[cur].ly : 0); + if (lineno > 0) + sprintf(position, "%d", lineno); + + if (editor_can_position() && *position) { #ifdef VMS - if ((strstr(editor, "sedt") || strstr(editor, "SEDT")) && - ((lineno - 1) + (nlinks ? links[cur].ly : 0)) > 0) { - sprintf(command, "%s %s -%d", - editor, - HTVMS_name("", filename), - ((lineno - 1) + (nlinks ? links[cur].ly : 0))); + format = "%s %s -%s"; + HTAddParam(&command, format, params++, editor); + HTAddParam(&command, format, params++, HTVMS_name("", filename)); + HTAddParam(&command, format, params++, position); + HTEndParam(&command, format, params); +#else + format = "%s +%s %s"; + HTAddParam(&command, format, params++, editor); + HTAddParam(&command, format, params++, position); + HTAddParam(&command, format, params++, HTSYS_name(filename)); + HTEndParam(&command, format, params); +#endif } else { - sprintf(command, "%s %s", editor, HTVMS_name("", filename)); + HTAddParam(&command, format, params++, editor); + HTAddParam(&command, format, params++, HTSYS_name(filename)); + HTEndParam(&command, format, params); } -#else - if (strstr(editor, "emacs") || strstr(editor, "vi") || - strstr(editor, "pico") || strstr(editor, "jove") || - strstr(editor, "jed")) - sprintf(command, "%s +%d \"%s\"", - editor, - (lineno + (nlinks ? links[cur].ly : 0)), - HTSYS_name(filename)); - else -#ifdef __DJGPP__ - sprintf(command, "%s %s", editor, HTDOS_name(filename)); -#else - sprintf(command, "%s \"%s\"", editor, HTSYS_name(filename)); -#endif /* __DJGPP__ */ -#endif /* VMS */ + CTRACE(tfp, "LYEdit: %s\n", command); CTRACE_SLEEP(MessageSecs); -#ifndef __EMX__ - FREE(filename); -#endif /* * Invoke the editor. - FM @@ -136,18 +154,16 @@ PUBLIC int edit_current_file ARGS3( LYSystem(command); start_curses(); - /* - * Restore the fragment if there was one. - FM - */ - if (number_sign) - *number_sign = '#'; - return TRUE; + result = TRUE; -failure: +done: /* * Restore the fragment if there was one. - FM */ if (number_sign) *number_sign = '#'; - return FALSE; + + FREE(command); + FREE(filename); + return (result); } diff --git a/src/LYEditmap.c b/src/LYEditmap.c index 8ba0d65c..a7e50807 100644 --- a/src/LYEditmap.c +++ b/src/LYEditmap.c @@ -18,7 +18,7 @@ LYE_NOP, LYE_BOL, LYE_DELPW, LYE_ABORT, LYE_DELN, LYE_EOL, LYE_DELNW, LYE_ABORT, /* ^D ^E ^F ^G */ -LYE_DELP, LYE_ENTER, LYE_ENTER, LYE_LOWER, +LYE_DELP, LYE_TAB, LYE_ENTER, LYE_LOWER, /* bs tab nl ^K */ LYE_NOP, LYE_ENTER, LYE_FORWW, LYE_ABORT, diff --git a/src/LYLocal.c b/src/LYLocal.c index e873f186..8d0c2aba 100644 --- a/src/LYLocal.c +++ b/src/LYLocal.c @@ -80,7 +80,7 @@ PRIVATE int LYExecv PARAMS(( PUBLIC char LYPermitFileURL[LY_MAXPATH] = "\0"; PUBLIC char LYDiredFileURL[LY_MAXPATH] = "\0"; -PRIVATE char *filename PARAMS(( +PRIVATE char *get_filename PARAMS(( char * prompt, char * buf, size_t bufsize)); @@ -309,7 +309,7 @@ PRIVATE int move_file ARGS2(char *, source, char *, target) return code; } -PRIVATE BOOLEAN already_exists ARGS1(char *, name) +PRIVATE BOOLEAN not_already_exists ARGS1(char *, name) { struct stat dir_info; @@ -585,7 +585,7 @@ PRIVATE BOOLEAN modify_name ARGS1( } else { return ok_file_or_dir(&dir_info); } - if (filename(cp, tmpbuf, sizeof(tmpbuf)) == NULL) + if (get_filename(cp, tmpbuf, sizeof(tmpbuf)) == NULL) return 0; /* @@ -603,7 +603,7 @@ PRIVATE BOOLEAN modify_name ARGS1( /* * Make sure the destination does not already exist. */ - if (!already_exists(newpath)) { + if (not_already_exists(newpath)) { return move_file(savepath, newpath); } } @@ -646,7 +646,7 @@ PRIVATE BOOLEAN modify_location ARGS1( } else { return ok_file_or_dir(&dir_info); } - if (filename(cp, tmpbuf, sizeof(tmpbuf)) == NULL) + if (get_filename(cp, tmpbuf, sizeof(tmpbuf)) == NULL) return 0; if (strlen(tmpbuf)) { strcpy(savepath, testpath); @@ -781,8 +781,8 @@ PRIVATE BOOLEAN create_file ARGS1( char *args[5]; char *bad_chars = ".~/"; - if (filename(gettext("Enter name of file to create: "), - tmpbuf, sizeof(tmpbuf)) == NULL) { + if (get_filename(gettext("Enter name of file to create: "), + tmpbuf, sizeof(tmpbuf)) == NULL) { return code; } @@ -804,7 +804,7 @@ PRIVATE BOOLEAN create_file ARGS1( /* * Make sure the target does not already exist */ - if (!already_exists(testpath)) { + if (not_already_exists(testpath)) { char *msg = 0; HTSprintf(&msg,gettext("create %s"),testpath); args[0] = "touch"; @@ -829,8 +829,8 @@ PRIVATE BOOLEAN create_directory ARGS1( char *args[5]; char *bad_chars = ".~/"; - if (filename(gettext("Enter name for new directory: "), - tmpbuf, sizeof(tmpbuf)) == NULL) { + if (get_filename(gettext("Enter name for new directory: "), + tmpbuf, sizeof(tmpbuf)) == NULL) { return code; } @@ -849,7 +849,7 @@ PRIVATE BOOLEAN create_directory ARGS1( /* * Make sure the target does not already exist. */ - if (!already_exists(testpath)) { + if (not_already_exists(testpath)) { char *msg = 0; HTSprintf(&msg,"make directory %s",testpath); args[0] = "mkdir"; @@ -1744,7 +1744,7 @@ PUBLIC int dired_options ARGS2( /* * Check DIRED filename. */ -PRIVATE char *filename ARGS3( +PRIVATE char *get_filename ARGS3( char *, prompt, char *, buf, size_t, bufsize) diff --git a/src/LYMain.c b/src/LYMain.c index 852a9c59..9204b984 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -1684,7 +1684,7 @@ PUBLIC int main ARGS2( */ StrAllocCopy(helpfilepath, helpfile); if ((cp = LYPathLeaf(helpfilepath)) != helpfilepath) - *cp = '\0'; + *cp = '\0'; LYAddHtmlSep(&helpfilepath); /* @@ -1747,7 +1747,9 @@ PUBLIC int main ARGS2( LYisConfiguredForX = TRUE; } ena_csi((LYlowest_eightbit[current_char_set] > 155)); + LYOpenCloset(); status = mainloop(); + LYCloseCloset(); cleanup(); exit(status); } diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index bbc076c2..0994de49 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -5009,7 +5009,9 @@ check_add_bookmark_to_self: break; } #endif /* VMS */ - fprintf(tfp, "\t\t%s\n\n", LYNX_TRACELOG_TITLE); + fprintf(tfp, "\t\t%s (%s)\n\n", + LYNX_TRACELOG_TITLE, + LYNX_VERSION); } HTUserMsg(WWW_TraceFlag ? TRACE_ON : TRACE_OFF); break; diff --git a/src/LYStrings.c b/src/LYStrings.c index 194d414f..71e50e28 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -25,6 +25,17 @@ extern unsigned short *LYKbLayout; extern BOOL HTPassHighCtrlRaw; extern HTCJKlang HTCJK; +/*Allowing the user to press tab when entering URL to get the closest + match in the closet*/ +#define LYClosetSize 100 +static char* LYCloset[LYClosetSize]; /* Closet with LYClosetSize shelves */ +static int LYClosetTop = 0; /*Points to the next empty shelf */ + +PRIVATE char *LYFindInCloset PARAMS(( + char* base)); +PRIVATE int LYAddToCloset PARAMS(( + char* str)); + /* If you want to add mouse support for some new platform, it's fairly ** simple to do. Once you've determined the X and Y coordinates of ** the mouse event, loop through the elements in the links[] array and @@ -2003,6 +2014,7 @@ PUBLIC int LYgetstr ARGS4( int x, y, MaxStringSize; int ch; EditFieldData MyEdit; + char *res; LYGetYX(y, x); /* Use screen from cursor position to eol */ MaxStringSize = (bufsize < sizeof(MyEdit.buffer)) ? @@ -2025,6 +2037,7 @@ again: #endif /* VMS */ if (recall && (ch == UPARROW || ch == DNARROW)) { strcpy(inputline, MyEdit.buffer); + LYAddToCloset(MyEdit.buffer); return(ch); } if (keymap[ch + 1] == LYK_REFRESH) @@ -2033,6 +2046,17 @@ again: case LYE_TAB: ch = '\t'; /* fall through */ + res = LYFindInCloset(MyEdit.buffer); + if (res != 0) { + LYEdit1(&MyEdit, '\0', LYE_ERASE, FALSE); + while (*res != '\0') { + LYLineEdit(&MyEdit, (int)(*res), FALSE); + res++; + } + } else { + ch = '\0'; + } + break; case LYE_AIX: /* * Hex 97. @@ -2051,6 +2075,7 @@ again: * Terminate the string and return. */ strcpy(inputline, MyEdit.buffer); + LYAddToCloset(MyEdit.buffer); return(ch); case LYE_ABORT: @@ -2515,6 +2540,61 @@ PUBLIC char * LYno_attr_mbcs_strstr ARGS5( return(NULL); } +PUBLIC void LYOpenCloset NOARGS +{ + /* We initialize the list-looka-like, i.e., the Closet */ + int i = 0; + while(i < LYClosetSize){ + LYCloset[i] = NULL; + i = i + 1; + } + LYClosetTop = 0; +} + +PUBLIC void LYCloseCloset NOARGS +{ + int i = 0; + + /* Clean up the list-looka-like, i.e., the Closet */ + while (i < LYClosetSize){ + FREE(LYCloset[i]); + i = i + 1; + } +} + +/* + * Strategy: We begin at the top and search downwards. We return the first + * match, i.e., the newest since we search from the top. This should be made + * more intelligent, but works for now. + */ +PRIVATE char * LYFindInCloset ARGS1(char*, base) +{ + int shelf; + unsigned len = strlen(base); + + shelf = (LYClosetTop - 1 + LYClosetSize) % LYClosetSize; + + while (LYCloset[shelf] != NULL){ + if (!strncmp(base, LYCloset[shelf], len)) { + return(LYCloset[shelf]); + } + shelf = (shelf - 1 + LYClosetSize) % LYClosetSize; + } + return(0); +} + +PRIVATE int LYAddToCloset ARGS1(char*, str) +{ + unsigned len = strlen(str); + + LYCloset[LYClosetTop] = malloc(len+1); + strcpy(LYCloset[LYClosetTop], str); + + LYClosetTop = (LYClosetTop + 1) % LYClosetSize; + FREE(LYCloset[LYClosetTop]); + return(1); +} + /* * Allocate a new copy of a string, and returns it. */ diff --git a/src/LYStrings.h b/src/LYStrings.h index 7bb6f95b..3d5d9a83 100644 --- a/src/LYStrings.h +++ b/src/LYStrings.h @@ -188,12 +188,14 @@ extern void LYSetupEdit PARAMS(( int maxdsp)); extern void LYRefreshEdit PARAMS(( EditFieldData * edit)); +extern int EditBinding PARAMS((int ch)); extern int LYEdit1 PARAMS(( EditFieldData * edit, int ch, int action, BOOL maxMessage)); - +extern void LYOpenCloset NOPARAMS; +extern void LYCloseCloset NOPARAMS; extern int current_lineedit; extern char * LYLineeditNames[]; |