1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -05:00

Merge with master

This commit is contained in:
Witold Filipczyk 2007-01-02 22:09:51 +01:00 committed by Witold Filipczyk
commit 07ea72242e
17 changed files with 348 additions and 92 deletions

262
NEWS
View File

@ -8,9 +8,265 @@ file for details.
ELinks now:
-----------
* Native FSP protocol support (replaces CGI program in contrib/fsp/)
* SEE Ecmascript backend
* Minimalistic RSS renderer
This list now contains all the important changes from ELinks 0.11.0 to
ELinks 0.12.GIT (26473f72f59641aa60277f14f703f8a76dda5a82). The next
step will be to scan through Bugzilla and look for bug numbers that
were not mentioned in related commit messages.
The list no doubt includes several changes that are not really
important enough. Please move them to the separate "should be removed
from NEWS" list below, or coalesce several changes into one entry (but
do list all bug numbers). It might be a good idea to sort the entries
roughly in decreasing order of importance.
* Miscellaneous
- (bugfix) If ELinks logs debug information to a file, it now opens
that in binary mode.
- (bugfix) Use PF_* instead of AF_* as first parameter of socket(2).
- (enhancement 752) Documentation updates
- (enhancement 381) Reduce memory consumption of codepages and some
other arrays.
- (bugfix) Secure file saving: restore umask after _all_ failure
conditions
- (bugfix 830) Fix misparsing of -remote URLs containing parenthesis.
- (bugfix 868) kill_timer from timer->func can crash check_timers.
- (enhancement 831) -remote openURL(URL) can include quoted commas.
- (enhancement) Reject invalid UTF-8 input from documents and
terminals.
* Changes in terminal support
- (new feature) Support for pasting from GNU screen clipboard
- (enhancement) Make ELinks FreeBSD friendly. Defined keys used on
FreeBSD console
- (enhancement) Mouse wheel support on BSD via moused -z 4
- (enhancement) Support for mouse wheel over GPM
- (experimental, new feature) UTF-8 as terminal charset: not merely
UTF-8 I/O of a unibyte codepage as in previous versions.
Double-cell (aka fullwidth) and non-BMP characters work too, but
combining characters and right-to-left text do not. The only
multibyte charset ELinks can decode is still UTF-8, so if the
server outputs e.g. Shift-JIS, you'd better recode with a proxy.
- (bugfix) Kill the ESC timer when blocking the terminal.
- (bugfix 724) Better parsing of escape sequences and control
sequences from the terminal.
- (bugfix) Decode UTF-8 only from bytes, not from codes of special
keys.
- (bugfix) Do not call toupper with potentially out-of-range values.
- (new feature) 24-bit truecolor mode
- (enhancement) "Resize terminal" tries to use the window size
increment.
- (new feature) Support Ctrl+Alt+letter key combinations.
- (bugfix) Subprocess forked for SIGTSTP calls _exit, not exit.
- (new feature 772) Recognize Shift+Tab on Xterm.
- (enhancement) Turn terminal transparency off by default.
- (bugfix 871) Lock down the numbering of terminal.*.colors
regardless of config options. This change makes elinks.conf
portable between different configurations but unfortunately not
between this and previous versions.
* Changes in cookies and bookmarks
- (new feature) "Add server" button in the cookie manager.
- (enhancement) Tell the user how to move bookmarks.
- (bugfix) Fix crash when moving bookmarks out of a folder.
- (bugfix) Fixed crash if XBEL bookmark has no title
- (bugfix 886) If the user edits or deletes a cookie, mark the
cookie list as needing to be saved.
- (enhancement 887) Save in cookie manager should save cookies even
if unmodified.
* Changes in the user interface
- (new feature) Internal clipboard support
- (enhancement) Place the cursor on the current listbox item, to
help screen readers
- (enhancement) Localization updates
- (bugfix 355) Add documents displayed via "What to do" dialog to
globhist
- (new feature) Autocreate directories needed to download a file.
- (new feature) Option ui.show_menu_bar_always
- (new feature) Option ui.tabs moves the tab bar to the top.
- (bugfix) Fix searching in menus past unselectable items.
- (bugfix) Fix crash with empty File extensions menu.
- (new feature) New actions: kill-word-back, move-backward-word,
move-forward-word
- (bugfix) Use internal OFF_T_FORMAT instead of PRId64
- (bugfix) Two small fixes in the authentication dialog.
- (enhancement) Ctrl+characters don't trigger hotkeys in menus and
dialogs.
- (bugfix 396) Never show empty filename in the what-to-do dialog
* Changes in support for URI schemes, protocols, caching, and encodings
- (workaround 841) SMB is now disabled because of CVE-2006-5925.
- (new feature) Native FSP protocol support (replaces CGI program in
contrib/fsp/)
- (new feature) Local CGI
- (experimental, bugfix) Gopher changes, including crash fixes
- (enhancement) FTP handler parses file sizes better
- (bugfix) Fixes cache-control issue. See elinks-users mail from 28 Oct 2005
- (new feature) LZMA decompression
- (bugfix) Local files in a directory whose name contained + were
unreachable.
- (new feature) HTTP negotiate-auth using GSSAPI
- (bugfix 769) HTTP digest auth computed MD5 from insufficient input.
- (bugfix 770) Download resuming simply restarts the download
- (bugfix) Fix IPv4 DNS lookup bug
- (bugfix) Fix null-pointer crash caused by malformed $HTTP_PROXY.
- (enhancement) If-Modified-Since and If-None-Match
- (bugfix) gzip_read: always call gzclearerr
- (bugfix 107) Recognize "localhost" in file: URIs.
- (bugfix 729) Fix crashes with various bogus BitTorrent URLs.
- (bugfix 756) "assertion (cached)->object.refcount >= 0 failed"
after HTTP proxy was changed
- (bugfix 899, Debian 403139) Fix size handling in FTP directory
listings.
- (bugfix 919) Fixed a buffer overflow when shrinking a cached fragment.
* Changes in parsing and rendering of HTML (without DOM)
- (enhancement) The list of SGML character entities has been updated
from unicode.org. However, it still isn't subsetted per DTD like
it probably should be.
- (new feature) Add support for forcing wrapping at the screen boundary
- (bugfix 741) HTML comments shouldn't be evaluated inside STYLE elements
- (bugfix) Use frame->name instead of target avoiding possible segfault.
- (bugfix 284) Render closing parentheses for HTML elements SUB, SUP
in the same line; don't let them fall to the next.
- (enhancement) Show quote characters for HTML element Q, rather
than italics.
- (enhancement) Add support for parsing space separated CSS class
attribute values
- (enhancement 767) HTML meta refresh finds the URL even without "URL=".
- (enhancement 396) If the server doesn't say what the Content-Type is
but the data contains "<html>", assume it is text/html.
- (bugfix 387) Treat &#013; inside <pre>...</pre> as a newline.
* Changes in parsing and rendering of non-HTML content-types
- (new feature) If a mailcap entry indicates copiousoutput, ELinks
itself acts as a pager.
- (new feature) Let plain text change colors with ESC [ 31 m or
similar control sequences.
* Changes in the document viewer and tabs
- (new feature) Highlight links as one enters link prefixes.
- (new feature) Backspace backs out the last digit of the prefix.
- (bugfix) Tabs opened by -remote now go behind existing dialogs.
- (new feature) -dump-color-mode
- (bugfix) Fix accesskeys so that they work when priority is 0
- (enhancement) Text type-ahead searching: don't follow current link
on enter
- (bugfix) Take the terminal charset in account when comparing
accesskeys.
- (enhancement) Display accesskeys as e.g. (Alt-f), not just (f).
- (bugfix) Decode the fragment identifier extracted from the URI
when looking it up
- (bugfix 908) radio button writes via a dangling pointer (potential
crash)
* Changes in user scripting
- (bugfix, Gentoo 121247) Ruby: Fix segfaults.
- (enhancement) Guile: Read hooks.scm rather than internal-hooks.scm.
(Keep reading user-hooks.scm, too.)
- (bugfix) Lua: current_document_formatted now works.
- (bugfix) Lua: Don't write to the string returned by lua_tostring.
- (experimental, new feature, bugfix) Python: Many additions and
bug fixes.
- (bugfix) SMJS: Don't complain about a missing hooks.js on startup.
- (new feature) SMJS: The elinks.preformat_html hook gets a second
argument: a view_state object with .uri and .plain properties.
- (enhancement) SMJS: elinks.alert no longer displays as an "error".
- (new feature) SMJS: New properties elinks.action, elinks.globhist,
elinks.vs.
- (new feature) SMJS: New function elinks.load_uri.
- (new feature) SMJS: New method elinks.execute.
- (enhancement) SMJS: Garbage-collect SMJS objects before flushing
caches.
- (bugfix 870) SMJS: Don't panic if a property ID is unrecognized.
(The bug also affected SMJS on web pages, but that's experimental.)
- (bitrot) Perl: Don't assume POPpx stores the length to n_a.
- (bugfix) Perl: Fix pre_format_html hook wrt. binary files.
* Build system and compile-time errors (ignore if you don't build ELinks)
- (bugfix) Fixed some bugs about compiling outside the source
directory.
- (bugfix) Don't use cmp -b, which FreeBSD doesn't support.
- (bugfix) Don't include <sys/param.h> for MIN and MAX because it
may interfere with CONFIG_IPV6 on Linux.
- (bugfix) When the configure script cleans old object files, this
no longer causes it to loop.
- (experimental, new feature) --with-python=DIRECTORY, --with-gc=DIRECTORY
- (bugfix) Include <sys/types.h> and fix compilation on an old
PPC/Debian system
- (bitrot) Fix compilation under gcc 4.x. Backported from gentoo portage.
- (bitrot) Update SpiderMonkey configure check Debian compatibility
- (new feature) Tiny C Compiler support
- (experimental, new feature) Native Win32 port
- (enhancement) If make -k was used and a sub-Make fails, build the
rest before propagating.
- (experimental, bitrot 768) Look for e.g. -lpython2.4 rather than
-lpython.
- (enhancement) Avoid compilation of vernum.c in 'make install'
- (bugfix) Don't use $(AM_CFLAGS) anymore. Use $(CPPFLAGS) instead.
- (bugfix) Fix compilation on Minix3.
- (new feature) make uninstall
- (bitrot) Fix two warnings on Mac OS X.
* (experimental) Changes in ECMAScript support
- (enhancement) Disable ECMAScript by default.
- (new feature) SEE ECMAScript backend, an alternative to SpiderMonkey.
- (new feature) Handling onsubmit
- (workaround) window.open remembers the last few URLs and doesn't
reopen them when incremental rendering reruns the onload script.
- (enhancement) Recognize document.location.href for SMJS.
- (enhancement) Better handling of form.action assignments
- (bugfix) SMJS: fix segfault on exit.
- (enhancement) form[x] looks up controls also by id, not only name.
- (new feature) New property input.selectedIndex.
- (new feature) Activate link only when onClick returns true.
- (enhancement) input.accessKey can be any Unicode character except
U+0000.
- (new feature) window.setTimeout, window.status
- (bugfix 846) Fix potentially exploitable crashes if properties
were invoked with "this" objects of unexpected types.
* (experimental) Changes in SGML/DOM implementation
- (new feature) Minimalistic RSS renderer
- (enhancement) Source highlighting also recognizes
application/xhtml+xml and application/docbook+xml. It doesn't yet
support arbitrary XML though.
- (enhancement) Make it possible to use more CSS properties with the
source highlighting
- (enhancement) Handle <base href=""> for HTML source rendering
- (enhancement) Add support for scanning comment endings such as
'--!>' correctly
- (new feature) Incremental parsing
- And more.
The following changes should be removed from NEWS before ELinks 0.12.0
is released. They are currently listed here just to show that they
have already been considered.
* Only partially fixed bugs:
- (bugfix 764) int/long type punning in options
- (bugfix 725) Fixes version checking for Ruby in 'configure'
* Fixed bugs that were not in previous versions:
- (bugfix) Fix a crash when adding a server in the cookie manager.
- (bugfix) cookies: "Add Server" ignores "cookies.accept_policy".
- (bugfix) Fix data: protocol.
- (bugfix) Properly deselect the main menu instead of crashing
- (bugfix 778) ELinks crashes on binary files when
document.plain.display_links is set
- (bugfix 784) UTF-8 mode misconverts non-ASCII entity in Latin-1
document
- (bugfix 782) UTF-8 buffer overwritten while in use
- (bugfix) switch_to_tab: Prevent "tab number out of range"
assertion failure.
- (bugfix) Fixed about:
- (bugfix 821) I cannot enter national characters in dialog boxes
- (bugfix 834) Gzip decompression doesn't work
- (bugfix) Fix out-of-bound access to the quote_char buffer
- (bugfix 880) Prevent SIGSEGV in init_python when -no-home is used.
- (bugfix 788) compile error with --enable-perl
- (bugfix 827) Crash with term charset set to Unicode and UTF-8 I/O
disabled
- (bugfix 826) too small table for double-cell characters
- (bugfix 902) crash: "overflow detected realloc()" in realloc_line
- (bugfix 912) wrong color in one cell of an HTML input field
* Reverted changes:
- (new feature) document.write, reverted in
2c087e52e74528a720621186b91880463e039d50
- (enhancement) restore Linux console mode (UTF-8 or not), reverted
in 10d72cae7eafa6b90db1c8f303deb200555734c2
- (enhancement) wcwidth, reverted in
d050cb67aa37390ab938b0a308c7541f19578506
* Unimportant changes:
- (enhancement) If select fails, save its errno.
ELinks 0.11.0 (Elated):
-----------------------

View File

@ -46,7 +46,7 @@ dumbprefixes = {
"sd" : "http://www.slashdot.org/"
}
def goto_url_hook(url, current_url):
def goto_url_hook(url):
"""Rewrite a URL that was entered in a "Go to URL" dialog box.
This function should return a URL for ELinks to follow, or None if
@ -55,8 +55,6 @@ def goto_url_hook(url, current_url):
Arguments:
url -- The URL provided by the user.
current_url -- The URL of the document being viewed, or None if no
document is being viewed.
"""
if url in dumbprefixes:
@ -136,13 +134,12 @@ class goto_url_in_new_tab:
"""Prompter that opens a given URL in a new tab."""
def __init__(self):
"""Prompt for a URL."""
self.current_location = elinks.current_url()
elinks.input_box("Enter URL", self._callback, title="Go to URL")
def _callback(self, url):
"""Open the given URL in a new tab."""
if 'goto_url_hook' in globals():
# Mimic the standard "Go to URL" dialog by calling goto_url_hook().
url = goto_url_hook(url, self.current_location) or url
url = goto_url_hook(url) or url
if url:
elinks.open(url, new_tab=True)
# The elinks.bind_key() function can be used to create a keystroke binding

View File

@ -44,7 +44,7 @@ FUNCTIONS
url -- The URL of the link.
goto_url_hook(url, current_url)
goto_url_hook(url)
Rewrite a URL that was entered in a "Go to URL" dialog box.
This function should return a URL for ELinks to follow, or None if
@ -53,8 +53,6 @@ FUNCTIONS
Arguments:
url -- The URL provided by the user.
current_url -- The URL of the document being viewed, or None if no
document is being viewed.
pre_format_html_hook(url, html)
Rewrite the body of a document before it's formatted.

View File

@ -71,7 +71,6 @@ $(srcdir)$(PACKAGE).pot: $(srcdir)$(POTFILES_ABS_LIST) $(srcdir)perl/gather-acce
# either <lang> or <lang>.po when calling make. Example: make update-po PO=is
update-po: Makefile $(srcdir)$(PACKAGE).pot
@test -z "$(srcdir)" || cd $(srcdir)
@$(foreach lang,$(basename $(if $(strip $(PO)),$(PO),$(GMOFILES))), \
echo -n "$(lang): "; \
if $(MSGMERGE) $(srcdir)$(lang).po $(srcdir)$(PACKAGE).pot -o $(lang).new.po; then \

View File

@ -195,7 +195,7 @@ print_xml_entities(struct secure_save_info *ssi, const unsigned char *str)
secure_fprintf(ssi, "&#%i;", (int) *str);
}
else {
unsigned char *s = u2cp_no_nbsp(*str, cp);
const unsigned char *s = u2cp_no_nbsp(*str, cp);
if (s) print_xml_entities(ssi, s);
}

View File

@ -70,7 +70,7 @@ struct codepage_desc {
#include "intl/entity.inc"
static char strings[256][2] = {
static const char strings[256][2] = {
"\000", "\001", "\002", "\003", "\004", "\005", "\006", "\007",
"\010", "\011", "\012", "\013", "\014", "\015", "\016", "\017",
"\020", "\021", "\022", "\023", "\024", "\025", "\026", "\033",
@ -117,7 +117,12 @@ free_translation_table(struct conv_table *p)
mem_free(p);
}
static unsigned char *no_str = "*";
/* A string used in conversion tables when there is no correct
* conversion. This is compared by address and therefore should be a
* named array rather than a pointer so that it won't share storage
* with any other string literal that happens to have the same
* characters. */
static const unsigned char no_str[] = "*";
static void
new_translation_table(struct conv_table *p)
@ -163,7 +168,7 @@ static const unicode_val_T strange_chars[32] = {
#define SYSTEM_CHARSET_FLAG 128
#define is_cp_ptr_utf8(cp_ptr) ((cp_ptr)->aliases == aliases_utf8)
unsigned char *
const unsigned char *
u2cp_(unicode_val_T u, int to, enum nbsp_mode nbsp_mode)
{
int j;
@ -251,7 +256,7 @@ encode_utf8(unicode_val_T u)
#ifdef CONFIG_UTF8
/* Number of bytes utf8 character indexed by first byte. Illegal bytes are
* equal ones and handled different. */
static char utf8char_len_tab[256] = {
static const char utf8char_len_tab[256] = {
1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,
@ -736,7 +741,7 @@ cp2u(int from, unsigned char c)
}
/* This slow and ugly code is used by the terminal utf_8_io */
unsigned char *
const unsigned char *
cp2utf8(int from, int c)
{
from &= ~SYSTEM_CHARSET_FLAG;
@ -767,7 +772,7 @@ cp_to_unicode(int codepage, unsigned char **string, unsigned char *end)
static void
add_utf8(struct conv_table *ct, unicode_val_T u, unsigned char *str)
add_utf8(struct conv_table *ct, unicode_val_T u, const unsigned char *str)
{
unsigned char *p = encode_utf8(u);
@ -796,6 +801,10 @@ add_utf8(struct conv_table *ct, unicode_val_T u, unsigned char *str)
ct[*p].u.str = str;
}
/* A conversion table from some charset to UTF-8.
* If it is from UTF-8 to UTF-8, it converts each byte separately.
* Unlike in other translation tables, the strings in elements 0x80 to
* 0xFF are allocated dynamically. */
struct conv_table utf_table[256];
int utf_table_init = 1;
@ -804,8 +813,9 @@ free_utf_table(void)
{
int i;
/* Cast away const. */
for (i = 128; i < 256; i++)
mem_free(utf_table[i].u.str);
mem_free((unsigned char *) utf_table[i].u.str);
}
static struct conv_table *
@ -857,7 +867,8 @@ get_translation_table_to_utf8(int from)
return utf_table;
}
struct conv_table table[256];
/* A conversion table between two charsets, where the target is not UTF-8. */
static struct conv_table table[256];
static int first = 1;
void
@ -917,7 +928,7 @@ get_translation_table(int from, int to)
for (i = 128; i < 256; i++) {
if (codepages[from].highhalf[i - 0x80] != 0xFFFF) {
unsigned char *u;
const unsigned char *u;
u = u2cp(codepages[from].highhalf[i - 0x80], to);
if (u) table[i].u.str = u;
@ -953,7 +964,7 @@ struct entity_cache {
unsigned int hits;
int strlen;
int encoding;
unsigned char *result;
const unsigned char *result;
unsigned char str[20]; /* Suffice in any case. */
};
@ -977,7 +988,7 @@ compare_entities(const void *key_, const void *element_)
return xxstrcmp(first, second, length);
}
unsigned char *
const unsigned char *
get_entity_string(const unsigned char *str, const int strlen, int encoding)
{
#define ENTITY_CACHE_SIZE 10 /* 10 seems a good value. */
@ -987,7 +998,7 @@ get_entity_string(const unsigned char *str, const int strlen, int encoding)
static unsigned int nb_entity_cache[ENTITY_CACHE_MAXLEN];
static int first_time = 1;
unsigned int slen = 0;
unsigned char *result = NULL;
const unsigned char *result = NULL;
if (strlen <= 0) return NULL;
@ -1181,7 +1192,7 @@ convert_string(struct conv_table *convert_table,
/* Iterate ;-) */
while (charspos < charslen) {
unsigned char *translit;
const unsigned char *translit;
#define PUTC do { \
buffer[bufferpos++] = chars[charspos++]; \

View File

@ -31,10 +31,24 @@ typedef uint32_t unicode_val_T;
#define NBSP_CHAR ((unsigned char) 1)
#define NBSP_CHAR_STRING "\001"
/* How to convert a byte from a source charset. This is used in an
* array (struct conv_table[256]) indexed by the byte value. */
struct conv_table {
/* 0 if this is the final byte of a character, or 1 if more
* bytes are needed. */
int t;
union {
unsigned char *str;
/* If @t==0: a null-terminated string that is the
* corresponding character in the target charset.
* Normally, the string is statically allocated.
* However, if the translation table is to UTF-8,
* then the strings in elements 0x80 to 0xFF are
* allocated with mem_alloc. */
const unsigned char *str;
/* If @t==1: a pointer to a nested conversion table
* (with 256 elements) that describes how to convert
* each possible subsequent byte. The conversion
* table owns the nested conversion table. */
struct conv_table *tbl;
} u;
};
@ -58,7 +72,8 @@ enum nbsp_mode {
};
struct conv_table *get_translation_table(int, int);
unsigned char *get_entity_string(const unsigned char *str, const int strlen, int encoding);
const unsigned char *get_entity_string(const unsigned char *str,
const int strlen, int encoding);
/* The convert_string() name is also used by Samba (version 3.0.3), which
* provides libnss_wins.so.2, which is called somewhere inside
@ -121,9 +136,9 @@ unicode_val_T cp_to_unicode(int, unsigned char **, unsigned char *);
#endif /* CONFIG_UTF8 */
unicode_val_T cp2u(int, unsigned char);
unsigned char *cp2utf8(int, int);
const unsigned char *cp2utf8(int, int);
unsigned char *u2cp_(unicode_val_T, int, enum nbsp_mode);
const unsigned char *u2cp_(unicode_val_T, int, enum nbsp_mode);
#define u2cp(u, to) u2cp_(u, to, NBSP_MODE_HACK)
#define u2cp_no_nbsp(u, to) u2cp_(u, to, NBSP_MODE_ASCII)

View File

@ -15,7 +15,6 @@
#include "main/event.h"
#include "protocol/uri.h"
#include "scripting/python/core.h"
#include "session/location.h"
#include "session/session.h"
#include "util/memory.h"
#include "util/string.h"
@ -64,28 +63,7 @@ script_hook_url(va_list ap, void *data)
python_ses = ses;
/*
* Historical note: The only reason the goto and follow hooks are
* treated differently is to maintain backwards compatibility for
* people who already have a goto_url_hook() function in hooks.py
* that expects a second argument. If we were starting over from
* scratch, we could treat the goto and follow hooks identically and
* simply pass @url as the sole argument in both cases; the Python
* code for the goto hook no longer needs its @current_url argument
* since it could instead determine the current URL by calling the
* Python interpreter's elinks.current_url() function.
*/
if (!strcmp(method, "goto_url_hook")) {
unsigned char *current_url = NULL;
if (python_ses && have_location(python_ses))
current_url = struri(cur_loc(ses)->vs.uri);
result = PyObject_CallMethod(python_hooks, method, "ss", *url,
current_url);
} else {
result = PyObject_CallMethod(python_hooks, method, "s", *url);
}
result = PyObject_CallMethod(python_hooks, method, "s", *url);
if (!result || !replace_with_python_string(url, result))
alert_python_error();

View File

@ -143,7 +143,7 @@ term_send_ucs(struct terminal *term, unicode_val_T u,
term_send_event(term, &ev);
#else /* !CONFIG_UTF8 */
struct term_event ev;
unsigned char *recoded;
const unsigned char *recoded;
set_kbd_term_event(&ev, KBD_UNDEF, modifier);
recoded = u2cp_no_nbsp(u, get_opt_codepage_tree(term->spec, "charset"));

View File

@ -52,7 +52,7 @@ er(int bell, int shall_sleep, unsigned char *fmt, va_list params)
}
int errline;
unsigned char *errfile;
const unsigned char *errfile;
void
elinks_debug(unsigned char *fmt, ...)

View File

@ -11,7 +11,7 @@
/* This errfile thing is needed, as we don't have var-arg macros in standart,
* only as gcc extension :(. */
extern int errline;
extern unsigned char *errfile;
extern const unsigned char *errfile;
/* @DBG(format_string) is used for printing of debugging information. It
* should not be used anywhere in the official codebase (although it is often

View File

@ -114,7 +114,7 @@ struct alloc_header {
#endif
int size;
int line;
unsigned char *file;
const unsigned char *file;
unsigned char *comment;
#ifdef CHECK_XFLOWS
@ -167,8 +167,8 @@ INIT_LIST_HEAD(memory_list);
#ifdef LOG_MEMORY_ALLOC
static void
dump_short_info(struct alloc_header *ah, unsigned char *file, int line,
unsigned char *type)
dump_short_info(struct alloc_header *ah, const unsigned char *file, int line,
const unsigned char *type)
{
fprintf(stderr, "%p", PTR_AH2BASE(ah)), fflush(stderr);
fprintf(stderr, ":%d", ah->size), fflush(stderr);
@ -184,8 +184,8 @@ dump_short_info(struct alloc_header *ah, unsigned char *file, int line,
#endif
static void
dump_info(struct alloc_header *ah, unsigned char *info,
unsigned char *file, int line, unsigned char *type)
dump_info(struct alloc_header *ah, const unsigned char *info,
const unsigned char *file, int line, const unsigned char *type)
{
fprintf(stderr, "%p", PTR_AH2BASE(ah)); fflush(stderr);
/* In some extreme cases, we may core here, as 'ah' can no longer point
@ -213,8 +213,8 @@ dump_info(struct alloc_header *ah, unsigned char *info,
#ifdef CHECK_AH_SANITY
static inline int
bad_ah_sanity(struct alloc_header *ah, unsigned char *info,
unsigned char *file, int line)
bad_ah_sanity(struct alloc_header *ah, const unsigned char *info,
const unsigned char *file, int line)
{
if (!ah) return 1;
if (ah->magic != AH_SANITY_MAGIC) {
@ -228,8 +228,8 @@ bad_ah_sanity(struct alloc_header *ah, unsigned char *info,
#ifdef CHECK_XFLOWS
static inline int
bad_xflow_magic(struct alloc_header *ah, unsigned char *info,
unsigned char *file, int line)
bad_xflow_magic(struct alloc_header *ah, const unsigned char *info,
const unsigned char *file, int line)
{
if (!ah) return 1;
@ -282,7 +282,7 @@ check_memory_leaks(void)
static int alloc_try = 0;
static int
patience(unsigned char *file, int line, unsigned char *of)
patience(const unsigned char *file, int line, const unsigned char *of)
{
errfile = file;
errline = line;
@ -310,7 +310,7 @@ patience(unsigned char *file, int line, unsigned char *of)
}
void *
debug_mem_alloc(unsigned char *file, int line, size_t size)
debug_mem_alloc(const unsigned char *file, int line, size_t size)
{
struct alloc_header *ah;
size_t true_size;
@ -354,7 +354,7 @@ debug_mem_alloc(unsigned char *file, int line, size_t size)
}
void *
debug_mem_calloc(unsigned char *file, int line, size_t eltcount, size_t eltsize)
debug_mem_calloc(const unsigned char *file, int line, size_t eltcount, size_t eltsize)
{
struct alloc_header *ah;
size_t size = eltcount * eltsize;
@ -405,7 +405,7 @@ debug_mem_calloc(unsigned char *file, int line, size_t eltcount, size_t eltsize)
}
void
debug_mem_free(unsigned char *file, int line, void *ptr)
debug_mem_free(const unsigned char *file, int line, void *ptr)
{
struct alloc_header *ah;
int ok = 1;
@ -485,7 +485,7 @@ debug_mem_free(unsigned char *file, int line, void *ptr)
}
void *
debug_mem_realloc(unsigned char *file, int line, void *ptr, size_t size)
debug_mem_realloc(const unsigned char *file, int line, void *ptr, size_t size)
{
struct alloc_header *ah, *ah2;
size_t true_size;
@ -558,7 +558,7 @@ debug_mem_realloc(unsigned char *file, int line, void *ptr, size_t size)
}
void
set_mem_comment(void *ptr, unsigned char *str, int len)
set_mem_comment(void *ptr, const unsigned char *str, int len)
{
struct alloc_header *ah;

View File

@ -12,11 +12,11 @@ struct mem_stats {
extern struct mem_stats mem_stats;
void *debug_mem_alloc(unsigned char *, int, size_t);
void *debug_mem_calloc(unsigned char *, int, size_t, size_t);
void debug_mem_free(unsigned char *, int, void *);
void *debug_mem_realloc(unsigned char *, int, void *, size_t);
void set_mem_comment(void *, unsigned char *, int);
void *debug_mem_alloc(const unsigned char *, int, size_t);
void *debug_mem_calloc(const unsigned char *, int, size_t, size_t);
void debug_mem_free(const unsigned char *, int, void *);
void *debug_mem_realloc(const unsigned char *, int, void *, size_t);
void set_mem_comment(void *, const unsigned char *, int);
void check_memory_leaks(void);

View File

@ -187,7 +187,7 @@ mem_mmap_realloc(void *p, size_t old_size, size_t new_size)
void *p2 = mem_mmap_alloc(new_size);
if (p2) {
memcpy(p2, p, old_size);
memcpy(p2, p, MIN(old_size, new_size));
mem_mmap_free(p, old_size);
return p2;
}

View File

@ -40,7 +40,7 @@
#ifdef DEBUG_MEMLEAK
unsigned char *
debug_memacpy(unsigned char *f, int l, unsigned char *src, int len)
debug_memacpy(const unsigned char *f, int l, const unsigned char *src, int len)
{
unsigned char *m;
@ -57,7 +57,7 @@ debug_memacpy(unsigned char *f, int l, unsigned char *src, int len)
}
unsigned char *
debug_stracpy(unsigned char *f, int l, unsigned char *src)
debug_stracpy(const unsigned char *f, int l, const unsigned char *src)
{
string_assert(f, l, src, "stracpy");
if_assert_failed return NULL;
@ -68,7 +68,7 @@ debug_stracpy(unsigned char *f, int l, unsigned char *src)
#else /* DEBUG_MEMLEAK */
unsigned char *
memacpy(unsigned char *src, int len)
memacpy(const unsigned char *src, int len)
{
unsigned char *m;
@ -85,7 +85,7 @@ memacpy(unsigned char *src, int len)
}
unsigned char *
stracpy(unsigned char *src)
stracpy(const unsigned char *src)
{
assertm(src, "[stracpy]");
if_assert_failed return NULL;
@ -116,7 +116,8 @@ add_to_strn(unsigned char **dst, unsigned char *src)
}
unsigned char *
insert_in_string(unsigned char **dst, int pos, unsigned char *seq, int seqlen)
insert_in_string(unsigned char **dst, int pos,
const unsigned char *seq, int seqlen)
{
int dstlen = strlen(*dst);
unsigned char *string = mem_realloc(*dst, dstlen + seqlen + 1);

View File

@ -25,17 +25,17 @@
/* Allocates NUL terminated string with @len bytes from @src.
* If @src == NULL or @len < 0 only one byte is allocated and set it to 0. */
/* Returns the string or NULL on allocation failure. */
unsigned char *memacpy(unsigned char *src, int len);
unsigned char *memacpy(const unsigned char *src, int len);
/* Allocated NUL terminated string with the content of @src. */
unsigned char *stracpy(unsigned char *src);
unsigned char *stracpy(const unsigned char *src);
#else /* DEBUG_MEMLEAK */
unsigned char *debug_memacpy(unsigned char *, int, unsigned char *, int);
unsigned char *debug_memacpy(const unsigned char *, int, const unsigned char *, int);
#define memacpy(s, l) debug_memacpy(__FILE__, __LINE__, s, l)
unsigned char *debug_stracpy(unsigned char *, int, unsigned char *);
unsigned char *debug_stracpy(const unsigned char *, int, const unsigned char *);
#define stracpy(s) debug_stracpy(__FILE__, __LINE__, s)
#endif /* DEBUG_MEMLEAK */
@ -47,8 +47,8 @@ void add_to_strn(unsigned char **str, unsigned char *src);
/* Inserts @seqlen chars from @seq at position @pos in the @dst string. */
/* If reallocation of @dst fails it is not touched and NULL is returned. */
unsigned char *
insert_in_string(unsigned char **dst, int pos, unsigned char *seq, int seqlen);
unsigned char *insert_in_string(unsigned char **dst, int pos,
const unsigned char *seq, int seqlen);
/* Takes a list of strings where the last parameter _must_ be NULL and
* concatenates them. */

View File

@ -1355,6 +1355,7 @@ field_op(struct session *ses, struct document_view *doc_view,
struct form_state *fs;
enum edit_action action_id;
unsigned char *text;
const unsigned char *ctext;
int length;
enum frame_event_status status = FRAME_EVENT_REFRESH;
#ifdef CONFIG_UTF8
@ -1748,19 +1749,19 @@ field_op(struct session *ses, struct document_view *doc_view,
if (ses->tab->term->utf8) {
/* fs->value is in UTF-8 regardless of
* the charset of the terminal. */
text = encode_utf8(get_kbd_key(ev));
ctext = encode_utf8(get_kbd_key(ev));
} else {
/* fs->value is in the charset of the
* terminal. */
int cp = get_opt_codepage_tree(ses->tab->term->spec,
"charset");
text = u2cp_no_nbsp(get_kbd_key(ev), cp);
ctext = u2cp_no_nbsp(get_kbd_key(ev), cp);
}
length = strlen(text);
length = strlen(ctext);
if (strlen(fs->value) + length > fc->maxlength
|| !insert_in_string(&fs->value, fs->state, text, length)) {
|| !insert_in_string(&fs->value, fs->state, ctext, length)) {
status = FRAME_EVENT_OK;
break;
}