[prev in list] [next in list] [prev in thread] [next in thread] 

List:       elinks-dev
Subject:    [elinks-dev] Re: Re: Descriptions
From:       Petr Baudis <pasky () ucw ! cz>
Date:       2003-10-25 0:52:05
Message-ID: 20031025005205.GC1075 () pasky ! ji ! cz
[Download RAW message or body]

Dear diary, on Fri, Oct 24, 2003 at 11:50:22AM CEST, I got a letter,
where Witold Filipczyk <witekfl@poczta.gazeta.pl> told me, that...
> --- elinks/src/config/conf.c	Tue Oct 21 00:25:07 2003
> +++ elinks.2/src/config/conf.c	Fri Oct 24 13:44:03 2003
> @@ -481,7 +481,6 @@
>  		       int action, int i18n)
>  {
>  	unsigned char *desc_i18n;
> -	int i, l;
>  
>  	/* When we're OPT_TREE, we won't get called with action 2 anyway and
>  	 * we want to pop out a comment. */
> @@ -517,22 +516,46 @@
>  				break;
>  
>  			desc_i18n = conf_i18n(option->desc, i18n);
> -			l = strlen(desc_i18n);
>  
>  			if (depth)
>  				add_xchar_to_string(string, ' ', depth * indentation);
>  			add_to_string(string, "# ");
> -
> -			for (i = 0; i < l; i++) {
> -				add_char_to_string(string, desc_i18n[i]);
> -				if (desc_i18n[i] == '\n') {
> -					if (depth)
> -						add_xchar_to_string(string, ' ',
> -								    depth * indentation);
> -					add_to_string(string, "# ");
> +			{
> +				unsigned char *i = desc_i18n;
> +				unsigned char *j = i;
> +				unsigned char *last_space = NULL;
> +				int config_width = 80;
> +				int n = depth * indentation + 2;
> +				int was_space = 0;

was_space looks redundant to !!last_space.

> +				
> +				for (;*i; i++, n++) {

*bzzt* missing whitespace ;-)

> +					if (*i == '\n') {
> +						add_bytes_to_string(string, j, i - j + 1);
> +						if (depth)
> +							add_xchar_to_string(string, ' ', depth * indentation);
> +						add_to_string(string, "# ");
> +						j = i + 1;
> +						n = depth * indentation + 1;
> +						was_space = 0;
> +						continue;
> +					}

Doesn't equivalent

if (*i == '\n') last_space = i;

look a little better than this block of code? ;-)

> +					if (*i == ' ') {
> +						was_space = 1;
> +						last_space = i;
> +					}
> +					if (n >= config_width && was_space) {
> +						add_bytes_to_string(string, j, last_space - j);
> +						add_char_to_string(string, '\n');
> +						if (depth)
> +							add_xchar_to_string(string, ' ', depth * indentation);
> +						add_to_string(string, "# ");
> +						j = last_space + 1;
> +						n = depth * indentation + 1 + i - last_space;
> +						was_space = 0;
> +					}
>  				}
> +				add_to_string(string, j);
>  			}
> -
>  			add_char_to_string(string, '\n');
>  			break;
>  


-- 
 
				Petr "Pasky" Baudis
.
To get something done, a committee should consist of no more than three
persons, two of them absent.
.
Stuff: http://pasky.ji.cz/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic