Re: save less

2015-11-06 Thread Theo de Raadt
>On Sat, Nov 07, 2015 at 12:12:55AM -0500, Michael McConville wrote:
>> Ted Unangst wrote:
>> > less has a peculiar estrdup function. unlike ecalloc etc., it only
>> > prints an error but doesn't quit. But the callers don't seem to check
>> > for null. And in many places they call a function called save()
>> > instead.
>> > 
>> > It is clearer to make estrdup() quit and use it everywhere.
>> 
>> ok mmcc@
>> 
>> That said, error()'s name very strongly implies that it quits, so we
>> should look into fixing that too.
>
>I don't think it implies anything of the sort, an error is still an
>error if it doesn't kill the program.

Feeling a lot of dejavu here.



Re: save less

2015-11-06 Thread Nicholas Marriott
On Sat, Nov 07, 2015 at 12:12:55AM -0500, Michael McConville wrote:
> Ted Unangst wrote:
> > less has a peculiar estrdup function. unlike ecalloc etc., it only
> > prints an error but doesn't quit. But the callers don't seem to check
> > for null. And in many places they call a function called save()
> > instead.
> > 
> > It is clearer to make estrdup() quit and use it everywhere.
> 
> ok mmcc@
> 
> That said, error()'s name very strongly implies that it quits, so we
> should look into fixing that too.

I don't think it implies anything of the sort, an error is still an
error if it doesn't kill the program.



Re: more utf8 less ebcdic

2015-11-06 Thread Nicholas Marriott
ok nicm



On Fri, Nov 06, 2015 at 10:40:19PM -0500, Ted Unangst wrote:
> Ted Unangst wrote:
> > Oops, that was the big bomb diff. We want to keep the nl_langinfo and some
> > charset support. Just remove the environment variable and pare down some of
> > the stranger charsets.
> 
> here's better working second half of the big bomb. we can init the charset 
> table
> with the ctype functions, and the utf-8 code actually does something quite
> different (with various amounts of correctness).
> 
> Index: charset.c
> ===
> RCS file: /cvs/src/usr.bin/less/charset.c,v
> retrieving revision 1.15
> diff -u -p -r1.15 charset.c
> --- charset.c 7 Nov 2015 03:30:52 -   1.15
> +++ charset.c 7 Nov 2015 03:36:07 -
> @@ -23,37 +23,6 @@
>  
>  int utf_mode = 0;
>  
> -/*
> - * Predefined character sets,
> - * selected by the LESSCHARSET environment variable.
> - */
> -struct charset {
> - char *name;
> - int *p_flag;
> - char *desc;
> -} charsets[] = {
> - /* BEGIN CSTYLED */
> - { "ascii",  NULL,   "8bcccbcc18b95.b" },
> - { "utf-8",  &utf_mode,   "8bcccbcc18b95.b126.bb" },
> - { NULL, NULL, NULL }
> - /* END CSTYLED */
> -};
> -
> -/*
> - * Support "locale charmap"/nl_langinfo(CODESET) values, as well as others.
> - */
> -struct cs_alias {
> - char *name;
> - char *oname;
> -} cs_aliases[] = {
> - { "UTF-8",  "utf-8" },
> - { "ANSI_X3.4-1968", "ascii" },
> - { "US-ASCII",   "ascii" },
> - { "646","ascii" },
> - { "C",  "ascii" },
> - { NULL, NULL }
> -};
> -
>  #define  IS_BINARY_CHAR  01
>  #define  IS_CONTROL_CHAR 02
>  
> @@ -62,109 +31,6 @@ static const char *binfmt = NULL;
>  static const char *utfbinfmt = NULL;
>  int binattr = AT_STANDOUT;
>  
> -
> -/*
> - * Define a charset, given a description string.
> - * The string consists of 256 letters,
> - * one for each character in the charset.
> - * If the string is shorter than 256 letters, missing letters
> - * are taken to be identical to the last one.
> - * A decimal number followed by a letter is taken to be a
> - * repetition of the letter.
> - *
> - * Each letter is one of:
> - *   . normal character
> - *   b binary character
> - *   c control character
> - */
> -static void
> -ichardef(char *s)
> -{
> - char *cp;
> - int n;
> - char v;
> -
> - n = 0;
> - v = 0;
> - cp = chardef;
> - while (*s != '\0') {
> - switch (*s++) {
> - case '.':
> - v = 0;
> - break;
> - case 'c':
> - v = IS_CONTROL_CHAR;
> - break;
> - case 'b':
> - v = IS_BINARY_CHAR|IS_CONTROL_CHAR;
> - break;
> -
> - case '0': case '1': case '2': case '3': case '4':
> - case '5': case '6': case '7': case '8': case '9':
> - n = (10 * n) + (s[-1] - '0');
> - continue;
> -
> - default:
> - error("invalid chardef", NULL_PARG);
> - quit(QUIT_ERROR);
> - /*NOTREACHED*/
> - }
> -
> - do {
> - if (cp >= chardef + sizeof (chardef)) {
> - error("chardef longer than 256", NULL_PARG);
> - quit(QUIT_ERROR);
> - /*NOTREACHED*/
> - }
> - *cp++ = v;
> - } while (--n > 0);
> - n = 0;
> - }
> -
> - while (cp < chardef + sizeof (chardef))
> - *cp++ = v;
> -}
> -
> -/*
> - * Define a charset, given a charset name.
> - * The valid charset names are listed in the "charsets" array.
> - */
> -static int
> -icharset(char *name, int no_error)
> -{
> - struct charset *p;
> - struct cs_alias *a;
> -
> - if (name == NULL || *name == '\0')
> - return (0);
> -
> - /* First see if the name is an alias. */
> - for (a = cs_aliases;  a->name != NULL;  a++) {
> - if (strcmp(name, a->name) == 0) {
> - name = a->oname;
> - break;
> - }
> - }
> -
> - for (p = charsets;  p->name != NULL;  p++) {
> - if (strcmp(name, p->name) == 0) {
> - ichardef(p->desc);
> - if (p->p_flag != NULL)
> - *(p->p_flag) = 1;
> - return (1);
> - }
> - }
> -
> - if (!no_error) {
> - error("invalid charset name", NULL_PARG);
> - quit(QUIT_ERROR);
> - }
> - return (0);
> -}
> -
> -/*
> - * Define a charset, given a locale name.
> - */
>  static void
>  ilocale(void)
>  {
> @@ -287,17 +153,10 @@ set_charset(void)
>  {
>   char *s;
>  
> - /*

Re: save less

2015-11-06 Thread Nicholas Marriott
Hmm I thought this was deliberate but looking at where estrdup is used
it is obviously not.  ok nicm



On Fri, Nov 06, 2015 at 11:07:26PM -0500, Ted Unangst wrote:
> less has a peculiar estrdup function. unlike ecalloc etc., it only prints an
> error but doesn't quit. But the callers don't seem to check for null. And in
> many places they call a function called save() instead.
> 
> It is clearer to make estrdup() quit and use it everywhere.
> 
> 
> Index: cmdbuf.c
> ===
> RCS file: /cvs/src/usr.bin/less/cmdbuf.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 cmdbuf.c
> --- cmdbuf.c  6 Nov 2015 15:50:33 -   1.9
> +++ cmdbuf.c  7 Nov 2015 04:04:50 -
> @@ -688,7 +688,7 @@ cmd_addhist(struct mlist *mlist, const c
>* Save the command and put it at the end of the history list.
>*/
>   ml = ecalloc(1, sizeof (struct mlist));
> - ml->string = save(cmd);
> + ml->string = estrdup(cmd);
>   ml->next = mlist;
>   ml->prev = mlist->prev;
>   mlist->prev->next = ml;
> @@ -1207,7 +1207,7 @@ histfile_name(void)
>   if (strcmp(name, "-") == 0 || strcmp(name, "/dev/null") == 0)
>   /* $LESSHISTFILE == "-" means don't use history file */
>   return (NULL);
> - return (save(name));
> + return (estrdup(name));
>   }
>  
>   /* Otherwise, file is in $HOME if enabled. */
> Index: command.c
> ===
> RCS file: /cvs/src/usr.bin/less/command.c,v
> retrieving revision 1.21
> diff -u -p -r1.21 command.c
> --- command.c 6 Nov 2015 15:58:01 -   1.21
> +++ command.c 7 Nov 2015 04:04:50 -
> @@ -203,7 +203,7 @@ exec_mca(void)
>   if (*cbuf == '\0')
>   every_first_cmd = NULL;
>   else
> - every_first_cmd = save(cbuf);
> + every_first_cmd = estrdup(cbuf);
>   break;
>   case A_OPT_TOGGLE:
>   toggle_option(curropt, opt_lower, cbuf, optflag);
> Index: decode.c
> ===
> RCS file: /cvs/src/usr.bin/less/decode.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 decode.c
> --- decode.c  6 Nov 2015 15:58:01 -   1.11
> +++ decode.c  7 Nov 2015 04:04:50 -
> @@ -680,9 +680,9 @@ add_hometable(char *envname, char *def_f
>   PARG parg;
>  
>   if (envname != NULL && (filename = lgetenv(envname)) != NULL)
> - filename = save(filename);
> + filename = estrdup(filename);
>   else if (sysvar)
> - filename = save(def_filename);
> + filename = estrdup(def_filename);
>   else
>   filename = homefile(def_filename);
>   if (filename == NULL)
> Index: edit.c
> ===
> RCS file: /cvs/src/usr.bin/less/edit.c,v
> retrieving revision 1.13
> diff -u -p -r1.13 edit.c
> --- edit.c6 Nov 2015 15:50:33 -   1.13
> +++ edit.c7 Nov 2015 04:04:50 -
> @@ -232,7 +232,7 @@ edit_ifile(IFILE ifile)
>   return (0);
>   }
>  
> - filename = save(get_filename(ifile));
> + filename = estrdup(get_filename(ifile));
>   /*
>* See if LESSOPEN specifies an "alternate" file to open.
>*/
> Index: filename.c
> ===
> RCS file: /cvs/src/usr.bin/less/filename.c,v
> retrieving revision 1.18
> diff -u -p -r1.18 filename.c
> --- filename.c6 Nov 2015 15:50:33 -   1.18
> +++ filename.c7 Nov 2015 04:04:50 -
> @@ -643,14 +643,14 @@ open_altfile(char *filename, int *pf, vo
>   if (returnfd > 1 && status == 0) {
>   *pfd = NULL;
>   *pf = -1;
> - return (save(FAKE_EMPTYFILE));
> + return (estrdup(FAKE_EMPTYFILE));
>   }
>   return (NULL);
>   }
>   ch_ungetchar(c);
>   *pfd = (void *) fd;
>   *pf = f;
> - return (save("-"));
> + return (estrdup("-"));
>   }
>   cmd = readfd(fd);
>   pclose(fd);
> Index: funcs.h
> ===
> RCS file: /cvs/src/usr.bin/less/funcs.h,v
> retrieving revision 1.10
> diff -u -p -r1.10 funcs.h
> --- funcs.h   6 Nov 2015 15:09:07 -   1.10
> +++ funcs.h   7 Nov 2015 04:04:50 -
> @@ -9,7 +9,6 @@
>  struct mlist;
>  struct loption;
>  
> -extern char *save(const char *);
>  extern void *ecalloc(int, unsigned int);
>  /*PRINTFLIKE1*/
>  extern char *easprintf(const char *, ...);
> Index: ifile.c
> ==

Re: save less

2015-11-06 Thread Michael McConville
Ted Unangst wrote:
> less has a peculiar estrdup function. unlike ecalloc etc., it only
> prints an error but doesn't quit. But the callers don't seem to check
> for null. And in many places they call a function called save()
> instead.
> 
> It is clearer to make estrdup() quit and use it everywhere.

ok mmcc@

That said, error()'s name very strongly implies that it quits, so we
should look into fixing that too.

> Index: cmdbuf.c
> ===
> RCS file: /cvs/src/usr.bin/less/cmdbuf.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 cmdbuf.c
> --- cmdbuf.c  6 Nov 2015 15:50:33 -   1.9
> +++ cmdbuf.c  7 Nov 2015 04:04:50 -
> @@ -688,7 +688,7 @@ cmd_addhist(struct mlist *mlist, const c
>* Save the command and put it at the end of the history list.
>*/
>   ml = ecalloc(1, sizeof (struct mlist));
> - ml->string = save(cmd);
> + ml->string = estrdup(cmd);
>   ml->next = mlist;
>   ml->prev = mlist->prev;
>   mlist->prev->next = ml;
> @@ -1207,7 +1207,7 @@ histfile_name(void)
>   if (strcmp(name, "-") == 0 || strcmp(name, "/dev/null") == 0)
>   /* $LESSHISTFILE == "-" means don't use history file */
>   return (NULL);
> - return (save(name));
> + return (estrdup(name));
>   }
>  
>   /* Otherwise, file is in $HOME if enabled. */
> Index: command.c
> ===
> RCS file: /cvs/src/usr.bin/less/command.c,v
> retrieving revision 1.21
> diff -u -p -r1.21 command.c
> --- command.c 6 Nov 2015 15:58:01 -   1.21
> +++ command.c 7 Nov 2015 04:04:50 -
> @@ -203,7 +203,7 @@ exec_mca(void)
>   if (*cbuf == '\0')
>   every_first_cmd = NULL;
>   else
> - every_first_cmd = save(cbuf);
> + every_first_cmd = estrdup(cbuf);
>   break;
>   case A_OPT_TOGGLE:
>   toggle_option(curropt, opt_lower, cbuf, optflag);
> Index: decode.c
> ===
> RCS file: /cvs/src/usr.bin/less/decode.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 decode.c
> --- decode.c  6 Nov 2015 15:58:01 -   1.11
> +++ decode.c  7 Nov 2015 04:04:50 -
> @@ -680,9 +680,9 @@ add_hometable(char *envname, char *def_f
>   PARG parg;
>  
>   if (envname != NULL && (filename = lgetenv(envname)) != NULL)
> - filename = save(filename);
> + filename = estrdup(filename);
>   else if (sysvar)
> - filename = save(def_filename);
> + filename = estrdup(def_filename);
>   else
>   filename = homefile(def_filename);
>   if (filename == NULL)
> Index: edit.c
> ===
> RCS file: /cvs/src/usr.bin/less/edit.c,v
> retrieving revision 1.13
> diff -u -p -r1.13 edit.c
> --- edit.c6 Nov 2015 15:50:33 -   1.13
> +++ edit.c7 Nov 2015 04:04:50 -
> @@ -232,7 +232,7 @@ edit_ifile(IFILE ifile)
>   return (0);
>   }
>  
> - filename = save(get_filename(ifile));
> + filename = estrdup(get_filename(ifile));
>   /*
>* See if LESSOPEN specifies an "alternate" file to open.
>*/
> Index: filename.c
> ===
> RCS file: /cvs/src/usr.bin/less/filename.c,v
> retrieving revision 1.18
> diff -u -p -r1.18 filename.c
> --- filename.c6 Nov 2015 15:50:33 -   1.18
> +++ filename.c7 Nov 2015 04:04:50 -
> @@ -643,14 +643,14 @@ open_altfile(char *filename, int *pf, vo
>   if (returnfd > 1 && status == 0) {
>   *pfd = NULL;
>   *pf = -1;
> - return (save(FAKE_EMPTYFILE));
> + return (estrdup(FAKE_EMPTYFILE));
>   }
>   return (NULL);
>   }
>   ch_ungetchar(c);
>   *pfd = (void *) fd;
>   *pf = f;
> - return (save("-"));
> + return (estrdup("-"));
>   }
>   cmd = readfd(fd);
>   pclose(fd);
> Index: funcs.h
> ===
> RCS file: /cvs/src/usr.bin/less/funcs.h,v
> retrieving revision 1.10
> diff -u -p -r1.10 funcs.h
> --- funcs.h   6 Nov 2015 15:09:07 -   1.10
> +++ funcs.h   7 Nov 2015 04:04:50 -
> @@ -9,7 +9,6 @@
>  struct mlist;
>  struct loption;
>  
> -extern char *save(const char *);
>  extern void *ecalloc(int, unsigned int);
>  /*PRINTFLIKE1*/
>  extern char *easprintf(const char *, ...);
> Index: ifile.c
> ===
> RCS file: /cvs/src/usr.

save less

2015-11-06 Thread Ted Unangst
less has a peculiar estrdup function. unlike ecalloc etc., it only prints an
error but doesn't quit. But the callers don't seem to check for null. And in
many places they call a function called save() instead.

It is clearer to make estrdup() quit and use it everywhere.


Index: cmdbuf.c
===
RCS file: /cvs/src/usr.bin/less/cmdbuf.c,v
retrieving revision 1.9
diff -u -p -r1.9 cmdbuf.c
--- cmdbuf.c6 Nov 2015 15:50:33 -   1.9
+++ cmdbuf.c7 Nov 2015 04:04:50 -
@@ -688,7 +688,7 @@ cmd_addhist(struct mlist *mlist, const c
 * Save the command and put it at the end of the history list.
 */
ml = ecalloc(1, sizeof (struct mlist));
-   ml->string = save(cmd);
+   ml->string = estrdup(cmd);
ml->next = mlist;
ml->prev = mlist->prev;
mlist->prev->next = ml;
@@ -1207,7 +1207,7 @@ histfile_name(void)
if (strcmp(name, "-") == 0 || strcmp(name, "/dev/null") == 0)
/* $LESSHISTFILE == "-" means don't use history file */
return (NULL);
-   return (save(name));
+   return (estrdup(name));
}
 
/* Otherwise, file is in $HOME if enabled. */
Index: command.c
===
RCS file: /cvs/src/usr.bin/less/command.c,v
retrieving revision 1.21
diff -u -p -r1.21 command.c
--- command.c   6 Nov 2015 15:58:01 -   1.21
+++ command.c   7 Nov 2015 04:04:50 -
@@ -203,7 +203,7 @@ exec_mca(void)
if (*cbuf == '\0')
every_first_cmd = NULL;
else
-   every_first_cmd = save(cbuf);
+   every_first_cmd = estrdup(cbuf);
break;
case A_OPT_TOGGLE:
toggle_option(curropt, opt_lower, cbuf, optflag);
Index: decode.c
===
RCS file: /cvs/src/usr.bin/less/decode.c,v
retrieving revision 1.11
diff -u -p -r1.11 decode.c
--- decode.c6 Nov 2015 15:58:01 -   1.11
+++ decode.c7 Nov 2015 04:04:50 -
@@ -680,9 +680,9 @@ add_hometable(char *envname, char *def_f
PARG parg;
 
if (envname != NULL && (filename = lgetenv(envname)) != NULL)
-   filename = save(filename);
+   filename = estrdup(filename);
else if (sysvar)
-   filename = save(def_filename);
+   filename = estrdup(def_filename);
else
filename = homefile(def_filename);
if (filename == NULL)
Index: edit.c
===
RCS file: /cvs/src/usr.bin/less/edit.c,v
retrieving revision 1.13
diff -u -p -r1.13 edit.c
--- edit.c  6 Nov 2015 15:50:33 -   1.13
+++ edit.c  7 Nov 2015 04:04:50 -
@@ -232,7 +232,7 @@ edit_ifile(IFILE ifile)
return (0);
}
 
-   filename = save(get_filename(ifile));
+   filename = estrdup(get_filename(ifile));
/*
 * See if LESSOPEN specifies an "alternate" file to open.
 */
Index: filename.c
===
RCS file: /cvs/src/usr.bin/less/filename.c,v
retrieving revision 1.18
diff -u -p -r1.18 filename.c
--- filename.c  6 Nov 2015 15:50:33 -   1.18
+++ filename.c  7 Nov 2015 04:04:50 -
@@ -643,14 +643,14 @@ open_altfile(char *filename, int *pf, vo
if (returnfd > 1 && status == 0) {
*pfd = NULL;
*pf = -1;
-   return (save(FAKE_EMPTYFILE));
+   return (estrdup(FAKE_EMPTYFILE));
}
return (NULL);
}
ch_ungetchar(c);
*pfd = (void *) fd;
*pf = f;
-   return (save("-"));
+   return (estrdup("-"));
}
cmd = readfd(fd);
pclose(fd);
Index: funcs.h
===
RCS file: /cvs/src/usr.bin/less/funcs.h,v
retrieving revision 1.10
diff -u -p -r1.10 funcs.h
--- funcs.h 6 Nov 2015 15:09:07 -   1.10
+++ funcs.h 7 Nov 2015 04:04:50 -
@@ -9,7 +9,6 @@
 struct mlist;
 struct loption;
 
-extern char *save(const char *);
 extern void *ecalloc(int, unsigned int);
 /*PRINTFLIKE1*/
 extern char *easprintf(const char *, ...);
Index: ifile.c
===
RCS file: /cvs/src/usr.bin/less/ifile.c,v
retrieving revision 1.9
diff -u -p -r1.9 ifile.c
--- ifile.c 6 Nov 2015 15:50:33 -   1.9
+++ ifile.c 7 Nov 2015 04:04:50 -
@@ -107,7 +107,7 @@ new_ifile(char *filename, struct ifile *
 * Allocate and initialize st

Re: more utf8 less ebcdic

2015-11-06 Thread Ted Unangst
Ted Unangst wrote:
> Oops, that was the big bomb diff. We want to keep the nl_langinfo and some
> charset support. Just remove the environment variable and pare down some of
> the stranger charsets.

here's better working second half of the big bomb. we can init the charset table
with the ctype functions, and the utf-8 code actually does something quite
different (with various amounts of correctness).

Index: charset.c
===
RCS file: /cvs/src/usr.bin/less/charset.c,v
retrieving revision 1.15
diff -u -p -r1.15 charset.c
--- charset.c   7 Nov 2015 03:30:52 -   1.15
+++ charset.c   7 Nov 2015 03:36:07 -
@@ -23,37 +23,6 @@
 
 int utf_mode = 0;
 
-/*
- * Predefined character sets,
- * selected by the LESSCHARSET environment variable.
- */
-struct charset {
-   char *name;
-   int *p_flag;
-   char *desc;
-} charsets[] = {
-   /* BEGIN CSTYLED */
-   { "ascii",  NULL,   "8bcccbcc18b95.b" },
-   { "utf-8",  &utf_mode,   "8bcccbcc18b95.b126.bb" },
-   { NULL, NULL, NULL }
-   /* END CSTYLED */
-};
-
-/*
- * Support "locale charmap"/nl_langinfo(CODESET) values, as well as others.
- */
-struct cs_alias {
-   char *name;
-   char *oname;
-} cs_aliases[] = {
-   { "UTF-8",  "utf-8" },
-   { "ANSI_X3.4-1968", "ascii" },
-   { "US-ASCII",   "ascii" },
-   { "646","ascii" },
-   { "C",  "ascii" },
-   { NULL, NULL }
-};
-
 #defineIS_BINARY_CHAR  01
 #defineIS_CONTROL_CHAR 02
 
@@ -62,109 +31,6 @@ static const char *binfmt = NULL;
 static const char *utfbinfmt = NULL;
 int binattr = AT_STANDOUT;
 
-
-/*
- * Define a charset, given a description string.
- * The string consists of 256 letters,
- * one for each character in the charset.
- * If the string is shorter than 256 letters, missing letters
- * are taken to be identical to the last one.
- * A decimal number followed by a letter is taken to be a
- * repetition of the letter.
- *
- * Each letter is one of:
- * . normal character
- * b binary character
- * c control character
- */
-static void
-ichardef(char *s)
-{
-   char *cp;
-   int n;
-   char v;
-
-   n = 0;
-   v = 0;
-   cp = chardef;
-   while (*s != '\0') {
-   switch (*s++) {
-   case '.':
-   v = 0;
-   break;
-   case 'c':
-   v = IS_CONTROL_CHAR;
-   break;
-   case 'b':
-   v = IS_BINARY_CHAR|IS_CONTROL_CHAR;
-   break;
-
-   case '0': case '1': case '2': case '3': case '4':
-   case '5': case '6': case '7': case '8': case '9':
-   n = (10 * n) + (s[-1] - '0');
-   continue;
-
-   default:
-   error("invalid chardef", NULL_PARG);
-   quit(QUIT_ERROR);
-   /*NOTREACHED*/
-   }
-
-   do {
-   if (cp >= chardef + sizeof (chardef)) {
-   error("chardef longer than 256", NULL_PARG);
-   quit(QUIT_ERROR);
-   /*NOTREACHED*/
-   }
-   *cp++ = v;
-   } while (--n > 0);
-   n = 0;
-   }
-
-   while (cp < chardef + sizeof (chardef))
-   *cp++ = v;
-}
-
-/*
- * Define a charset, given a charset name.
- * The valid charset names are listed in the "charsets" array.
- */
-static int
-icharset(char *name, int no_error)
-{
-   struct charset *p;
-   struct cs_alias *a;
-
-   if (name == NULL || *name == '\0')
-   return (0);
-
-   /* First see if the name is an alias. */
-   for (a = cs_aliases;  a->name != NULL;  a++) {
-   if (strcmp(name, a->name) == 0) {
-   name = a->oname;
-   break;
-   }
-   }
-
-   for (p = charsets;  p->name != NULL;  p++) {
-   if (strcmp(name, p->name) == 0) {
-   ichardef(p->desc);
-   if (p->p_flag != NULL)
-   *(p->p_flag) = 1;
-   return (1);
-   }
-   }
-
-   if (!no_error) {
-   error("invalid charset name", NULL_PARG);
-   quit(QUIT_ERROR);
-   }
-   return (0);
-}
-
-/*
- * Define a charset, given a locale name.
- */
 static void
 ilocale(void)
 {
@@ -287,17 +153,10 @@ set_charset(void)
 {
char *s;
 
-   /*
-* Try using the codeset name as the charset name.
-*/
s = nl_langinfo(CODESET);
-   if (icharset(s, 1))
-   return;
+   if (s && strcasecmp(s, "utf-8") == 0)
+   utf_mode = 1;
 
-   

[patch] armv7/imx/imxesdhc.c: add imxesdhc_dump_regs

2015-11-06 Thread kremlin
Hello,

This patch adds a debugging function dumping the contents of all
registers implicated in the armv7/imx specific sd/mmc controller. It
only prints if the kernel is built with option SDHC_DEBUG and a call is
inserted somewhere.

I am trying to fix the outstanding bug causing the imxesdhc driver to
timeout upon block reads (CMD17) which prevents any meaningful I/O with
"disks" on i.MX6 platforms. If anyone has any helpful pointers to this
end, please respond on-list or to i...@kremlin.cc

Thanks,
Ian

Index: imx/imxesdhc.c
===
RCS file: /cvs/src/sys/arch/armv7/imx/imxesdhc.c,v
retrieving revision 1.12
diff -u -p -r1.12 imxesdhc.c
--- imx/imxesdhc.c  30 May 2015 03:20:54 -  1.12
+++ imx/imxesdhc.c  7 Nov 2015 00:50:08 -
@@ -208,11 +208,76 @@ void  imxesdhc_read_data(struct imxesdhc_
 void   imxesdhc_write_data(struct imxesdhc_softc *, u_char *, int);
 
 //#define SDHC_DEBUG
+void   imxesdhc_dump_regs(struct imxesdhc_softc *);
 #ifdef SDHC_DEBUG
 int imxesdhcdebug = 20;
 #define DPRINTF(n,s)   do { if ((n) <= imxesdhcdebug) printf s; } while (0)
+void
+imxesdhc_dump_regs(struct imxesdhc_softc *sc)
+{
+   DPRINTF(3, ("%s: SDHC_DS_ADDR: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_DS_ADDR)));
+   DPRINTF(3, ("%s: SDHC_BLK_ATT: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_BLK_ATT)));
+   DPRINTF(3, ("%s: SDHC_CMD_ARG: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_CMD_ARG)));
+   DPRINTF(3, ("%s: SDHC_CMD_XFR_TYP: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_CMD_XFR_TYP)));
+   DPRINTF(3, ("%s: SDHC_CMD_RSP0: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_CMD_RSP0)));
+   DPRINTF(3, ("%s: SDHC_CMD_RSP1: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_CMD_RSP1)));
+   DPRINTF(3, ("%s: SDHC_CMD_RSP2: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_CMD_RSP2)));
+   DPRINTF(3, ("%s: SDHC_CMD_RSP3: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_CMD_RSP3)));
+   DPRINTF(3, ("%s: SDHC_DATA_BUFF_ACC_PORT: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_DATA_BUFF_ACC_PORT)));
+   DPRINTF(3, ("%s: SDHC_PRES_STATE: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_PRES_STATE)));
+   DPRINTF(3, ("%s: SDHC_PROT_CTRL: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_PROT_CTRL)));
+   DPRINTF(3, ("%s: SDHC_SYS_CTRL: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_SYS_CTRL)));
+   DPRINTF(3, ("%s: SDHC_INT_STATUS: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_INT_STATUS)));
+   DPRINTF(3, ("%s: SDHC_INT_STATUS_EN: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_INT_STATUS_EN)));
+   DPRINTF(3, ("%s: SDHC_INT_SIGNAL_EN: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_INT_SIGNAL_EN)));
+   DPRINTF(3, ("%s: SDHC_AUTOCMD12_ERR_STATUS: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_AUTOCMD12_ERR_STATUS)));
+   DPRINTF(3, ("%s: SDHC_HOST_CTRL_CAP: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_HOST_CTRL_CAP)));
+   DPRINTF(3, ("%s: SDHC_WTMK_LVL: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_WTMK_LVL)));
+   DPRINTF(3, ("%s: SDHC_MIX_CTRL: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_MIX_CTRL)));
+   DPRINTF(3, ("%s: SDHC_FORCE_EVENT: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_FORCE_EVENT)));
+   DPRINTF(3, ("%s: SDHC_ADMA_ERR_STATUS: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_ADMA_ERR_STATUS)));
+   DPRINTF(3, ("%s: SDHC_ADMA_SYS_ADDR: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_ADMA_SYS_ADDR)));
+   DPRINTF(3, ("%s: SDHC_DLL_CTRL: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_DLL_CTRL)));
+   DPRINTF(3, ("%s: SDHC_DLL_STATUS: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_DLL_STATUS)));
+   DPRINTF(3, ("%s: SDHC_CLK_TUNE_CTRL_STATUS: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_CLK_TUNE_CTRL_STATUS)));
+   DPRINTF(3, ("%s: SDHC_VEND_SPEC: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_VEND_SPEC)));
+   DPRINTF(3, ("%s: SDHC_MMC_BOOT: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_MMC_BOOT)));
+   DPRINTF(3, ("%s: SDHC_VEND_SPEC2: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_VEND_SPEC2)));
+   DPRINTF(3, ("%s: SDHC_HOST_CTRL_VER: 0x%08x\n",
+   DEVNAME(sc), HREAD4(sc, SDHC_HOST_CTRL_VER)));
+}
 #else
 #define DPRINTF(n,s)   do {} while(0)
+void
+imxesdhc_dump_regs(struct imxesdhc_softc *sc) {}
 #endif
 
 struct sdmmc_chip_functions imxesdhc_functions = {



cron: use __progname

2015-11-06 Thread Todd C. Miller
Use __progname in cron/crontab/at instead of the homegrown ProgramName.
Also get rid of MAIN_PROGRAM and XTRN which are not needed in modern
C.

 - todd

Index: usr.bin/at/at.c
===
RCS file: /cvs/src/usr.bin/at/at.c,v
retrieving revision 1.68
diff -u -p -u -r1.68 at.c
--- usr.bin/at/at.c 4 Nov 2015 20:28:17 -   1.68
+++ usr.bin/at/at.c 6 Nov 2015 22:01:34 -
@@ -31,8 +31,6 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#defineMAIN_PROGRAM
-
 #include 
 #include 
 
@@ -100,7 +98,7 @@ time_t parsetime(int, char **);
 static __dead void
 panic(const char *a)
 {
-   (void)fprintf(stderr, "%s: %s\n", ProgramName, a);
+   (void)fprintf(stderr, "%s: %s\n", __progname, a);
if (fcreated)
unlink(atfile);
 
@@ -113,7 +111,7 @@ panic(const char *a)
 static __dead void
 panic2(const char *a, const char *b)
 {
-   (void)fprintf(stderr, "%s: %s%s\n", ProgramName, a, b);
+   (void)fprintf(stderr, "%s: %s%s\n", __progname, a, b);
if (fcreated)
unlink(atfile);
 
@@ -498,7 +496,7 @@ list_jobs(int argc, char **argv, int cou
} else
uids = NULL;
 
-   shortformat = strcmp(ProgramName, "at") == 0;
+   shortformat = strcmp(__progname, "at") == 0;
 
if (chdir(AT_DIR) != 0)
perr2("Cannot change to ", AT_DIR);
@@ -660,7 +658,7 @@ process_jobs(int argc, char **argv, int 
if (user_uid != pw->pw_uid && user_uid != 0) {
fprintf(stderr, "%s: Only the superuser"
" may %s other users' jobs\n",
-   ProgramName, what == ATRM
+   __progname, what == ATRM
? "remove" : "view");
exit(EXIT_FAILURE);
}
@@ -745,7 +743,7 @@ process_jobs(int argc, char **argv, int 
if (jobs[i] != NULL) {
if (!force)
fprintf(stderr, "%s: %s: no such job\n",
-   ProgramName, jobs[i]);
+   __progname, jobs[i]);
error++;
}
}
@@ -908,23 +906,18 @@ main(int argc, char **argv)
if (argc < 1)
usage();
 
-   if ((ProgramName = strrchr(argv[0], '/')) != NULL)
-   ProgramName++;
-   else
-   ProgramName = argv[0];
-
user_uid = getuid();
user_gid = getgid();
spool_gid = getegid();
 
/* find out what this program is supposed to do */
-   if (strcmp(ProgramName, "atq") == 0) {
+   if (strcmp(__progname, "atq") == 0) {
program = ATQ;
options = "cnvq:";
-   } else if (strcmp(ProgramName, "atrm") == 0) {
+   } else if (strcmp(__progname, "atrm") == 0) {
program = ATRM;
options = "afi";
-   } else if (strcmp(ProgramName, "batch") == 0) {
+   } else if (strcmp(__progname, "batch") == 0) {
program = BATCH;
options = "f:q:mv";
}
Index: usr.bin/at/parsetime.c
===
RCS file: /cvs/src/usr.bin/at/parsetime.c,v
retrieving revision 1.23
diff -u -p -u -r1.23 parsetime.c
--- usr.bin/at/parsetime.c  20 Aug 2015 22:32:41 -  1.23
+++ usr.bin/at/parsetime.c  6 Nov 2015 21:59:37 -
@@ -182,7 +182,7 @@ init_scanner(int argc, char **argv)
 
if ((sc_token = malloc(sc_len)) == NULL) {
fprintf(stderr, "%s: Insufficient virtual memory\n",
-   ProgramName);
+   __progname);
return (-1);
}
return (0);
@@ -264,7 +264,7 @@ token(void)
 static void
 plonk(int tok)
 {
-   fprintf(stderr, "%s: %s time\n", ProgramName,
+   fprintf(stderr, "%s: %s time\n", __progname,
(tok == EOF) ? "incomplete" : "garbled");
 }
 
@@ -368,7 +368,7 @@ plus(struct tm *tm)
case MINUTES:
if (expectplur != sc_tokplur)
fprintf(stderr, "%s: pluralization is wrong\n",
-   ProgramName);
+   __progname);
dateadd(increment, tm);
return (0);
}
@@ -446,7 +446,7 @@ tod(struct tm *tm)
}
return (0);
 bad:
-   fprintf(stderr, "%s: garbled time\n", ProgramName);
+   fprintf(stderr, "%s: garbled time\n", __progname);
return (-1);
 }
 
@@ -607,7 +607,7 @@ month(struct tm *tm)
}
return (0);
 bad:
-   fprintf(stderr, "%s: garbled time\n", ProgramName);
+   fprintf(stderr, "%s: garbled time\n", __progname);
return (-1);
 }
 
@@ -700,1

Re: PC Engines APU2 coming soon - how is OpenBSD's support so far?

2015-11-06 Thread Brian Conway
Not much different to report with the 2 GB model, other than the
expected changes in memory size and ethernet chips. Everything seems
to work well.

Taking into account Mr. Cappuccio's advice on using thermal paste
between the CPU and heat spreader, and also positioning it bottom-up,
this one stabilized at 51 C at idle. I haven't had a chance to do much
benchmarking for higher temps yet, other than a run of `openssl speed`
to warm it up.

Brian Conway

OpenBSD 5.8-current (GENERIC.MP) #1574: Thu Nov  5 22:51:41 MST 2015
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 1996152832 (1903MB)
avail mem = 1931587584 (1842MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.7 @ 0x77fb7020 (7 entries)
bios0: vendor coreboot version "APU2A_20150924-3-g0bf9198-dirty" date 09/28/2015
bios0: PC Engines apu2
acpi0 at bios0: rev 2
acpi0: sleep states S0 S1 S2 S3 S4 S5
acpi0: tables DSDT FACP SSDT APIC HEST SSDT SSDT HPET
acpi0: wakeup devices PWRB(S4) PBR4(S4) PBR5(S4) PBR6(S4) PBR7(S4)
PBR8(S4) UOH1(S3) UOH3(S3) UOH5(S3) XHC0(S4)
acpitimer0 at acpi0: 3579545 Hz, 32 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: AMD GX-412TC SOC, 998.25 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,TOPEXT,ITSC,BMI1
cpu0: 32KB 64b/line 2-way I-cache, 32KB 64b/line 8-way D-cache, 2MB
64b/line 16-way L2 cache
cpu0: ITLB 32 4KB entries fully associative, 8 4MB entries fully associative
cpu0: DTLB 40 4KB entries fully associative, 8 4MB entries fully associative
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 99MHz
cpu0: mwait min=64, max=64, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: AMD GX-412TC SOC, 998.13 MHz
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,TOPEXT,ITSC,BMI1
cpu1: 32KB 64b/line 2-way I-cache, 32KB 64b/line 8-way D-cache, 2MB
64b/line 16-way L2 cache
cpu1: ITLB 32 4KB entries fully associative, 8 4MB entries fully associative
cpu1: DTLB 40 4KB entries fully associative, 8 4MB entries fully associative
cpu1: smt 0, core 1, package 0
cpu2 at mainbus0: apid 2 (application processor)
cpu2: AMD GX-412TC SOC, 998.13 MHz
cpu2: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,TOPEXT,ITSC,BMI1
cpu2: 32KB 64b/line 2-way I-cache, 32KB 64b/line 8-way D-cache, 2MB
64b/line 16-way L2 cache
cpu2: ITLB 32 4KB entries fully associative, 8 4MB entries fully associative
cpu2: DTLB 40 4KB entries fully associative, 8 4MB entries fully associative
cpu2: smt 0, core 2, package 0
cpu3 at mainbus0: apid 3 (application processor)
cpu3: AMD GX-412TC SOC, 998.13 MHz
cpu3: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,TOPEXT,ITSC,BMI1
cpu3: 32KB 64b/line 2-way I-cache, 32KB 64b/line 8-way D-cache, 2MB
64b/line 16-way L2 cache
cpu3: ITLB 32 4KB entries fully associative, 8 4MB entries fully associative
cpu3: DTLB 40 4KB entries fully associative, 8 4MB entries fully associative
cpu3: smt 0, core 3, package 0
ioapic0 at mainbus0: apid 4 pa 0xfec0, version 21, 24 pins
ioapic1 at mainbus0: apid 5 pa 0xfec2, version 21, 32 pins
ioapic1: misconfigured as apic 0, remapped to apid 5
acpihpet0 at acpi0: 14318180 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (PBR4)
acpiprt2 at acpi0: bus 1 (PBR5)
acpiprt3 at acpi0: bus 2 (PBR6)
acpiprt4 at acpi0: bus 3 (PBR7)
acpiprt5 at acpi0: bus -1 (PBR8)
acpicpu0 at acpi0: !C2(0@400 io@0x1771), C1(@1 halt!), PSS
acpicpu1 at acpi0: !C2(0@400 io@0x1771), C1(@1 halt!), PSS
acpicpu2 at acpi0: !C2(0@400 io@0x1771), C1(@1 halt!), PSS
acpicpu3 at acpi0: !C2(0@400 io@0x1771), C1(@1 halt!), PSS
acpibtn0 at acpi0: PWRB
cpu0: 998 MHz: speeds: 1000 800 600 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "AMD AMD64 16h Root Complex" rev 0x00
pchb1 at pci0 dev 2 function 0 "AMD AMD64 16h Host" rev 0x00
ppb0 at pci0 dev 2 function 2 "AMD AMD64 16h PCIE" rev 0x00: msi
pci1 at ppb0 bus 1
em0 at pci1 dev 0 function 0 "Intel I211" rev 0x03: msi, address
00:0d:b9:3f:9d:84
ppb1 at pci

Re: LibreSSL MIPS64 build with GCC5

2015-11-06 Thread Miod Vallat
> Thanks for feedback Michael! I wasn't aware of __GNUC_PREREQ.
> I did a grep and found a few more places where it can be used.

But __GNUC_PREREQ may not be available everywhere LibreSSL is built, so
it is better to stick to explicit tests for the time being. I have fixed
the test to handle gcc >= 5.x correctly.



Re: fix CRYPTO_chacha_20() on BE32 platforms

2015-11-06 Thread Miod Vallat
> Hi,
> 
> On Fri, Nov 06, 2015 at 05:39:03AM +, Miod Vallat wrote:
> > Running regress/lib/libcrypto/aead fails on big-endian platforms without
> > the following diff, for the ``Test vector from RFC7539 2.8.2'' test, due
> > to 64-bit counters being truncated to size_t.
> > 
> 
> Yes, the counter should be unsigned 64bit.
> 
> OK reyk@

But note that will require a .so major version bump, as the API changes
on 32-bit systems.

> I can only see one other *int64_t in LibreSSL's API, should it be
> unsigned long long?  Or is it OK to start using C99 types in the API? (yes!)

 types are definitely welcome.

> The comment "converting size_t to u8" should also be updated:

Indeed. Thanks for noticing.



Re: cwm users (M1 menu change)

2015-11-06 Thread Bryan Steele
On Fri, Nov 06, 2015 at 12:47:08PM -0500, Okan Demirmen wrote:
> For 2 reasons, I'd like to change M1 (mouse-button1) menu from
> displaying only hidden windows to showing all windows.
>   - this is the only menu that differs between mouse and keyboard
> invocations (kbd one shows all)
>   - allows using this menu to switch to unhidden/showing windows
> that happen to be on another screen (but still visable)
> 
> Of course, search_print_client() will anotate each client's state, such
> as done in other menus.
> 
> Minimal diff below, leaving out the renaming and related stuff so it's
> not referenced only as 'unhide'.
> 
> Objections?
> 
> Thanks,
> Okan
> 
> Index: cwm.1
> ===
> RCS file: /home/open/cvs/xenocara/app/cwm/cwm.1,v
> retrieving revision 1.53
> diff -u -p -r1.53 cwm.1
> --- cwm.1 21 Aug 2015 16:52:37 -  1.53
> +++ cwm.1 6 Nov 2015 17:39:33 -
> @@ -224,8 +224,8 @@ Menus are recalled by clicking the mouse
>  .Pp
>  .Bl -tag -width Ds -offset indent -compact
>  .It Ic M1
> -Show list of currently hidden windows.
> -Selecting an item will unhide that window.
> +Show the list of windows.
> +Selecting an item will unhide, if nessecary, and warp to that window.
>  .It Ic M2
>  Show list of currently defined groups.
>  Selecting an item will hide/unhide that group.
> Index: mousefunc.c
> ===
> RCS file: /home/open/cvs/xenocara/app/cwm/mousefunc.c,v
> retrieving revision 1.98
> diff -u -p -r1.98 mousefunc.c
> --- mousefunc.c   21 Aug 2015 16:14:39 -  1.98
> +++ mousefunc.c   6 Nov 2015 17:21:08 -
> @@ -207,15 +207,14 @@ mousefunc_menu_unhide(struct client_ctx 
>  
>   TAILQ_INIT(&menuq);
>   TAILQ_FOREACH(cc, &sc->clientq, entry) {
> - if (cc->flags & CLIENT_HIDDEN) {
> - menuq_add(&menuq, cc, NULL);
> - }
> + menuq_add(&menuq, cc, NULL);
>   }
>  
>   if ((mi = menu_filter(sc, &menuq, NULL, NULL, CWM_MENU_LIST,
>   NULL, search_print_client)) != NULL) {
>   cc = (struct client_ctx *)mi->ctx;
> - client_unhide(cc);
> + if (cc->flags & CLIENT_HIDDEN)
> + client_unhide(cc);
>   if (old_cc != NULL)
>   client_ptrsave(old_cc);
>   client_ptrwarp(cc);
>

At least for me I wasn't previously using the M-/ C-A combo very often
and instead only used M1 to see a listen of windows I previously hidden
using CM-Return.

This will change my usage patterns for cwm, I'll have to pay attention
to window list flags (& !) that I was previously ignoring.

I also don't normally use the groups either, but I suppose I may be in
the minority.. so if this helps most users..

-Bryan.



cwm users (M1 menu change)

2015-11-06 Thread Okan Demirmen
For 2 reasons, I'd like to change M1 (mouse-button1) menu from
displaying only hidden windows to showing all windows.
- this is the only menu that differs between mouse and keyboard
  invocations (kbd one shows all)
- allows using this menu to switch to unhidden/showing windows
  that happen to be on another screen (but still visable)

Of course, search_print_client() will anotate each client's state, such
as done in other menus.

Minimal diff below, leaving out the renaming and related stuff so it's
not referenced only as 'unhide'.

Objections?

Thanks,
Okan

Index: cwm.1
===
RCS file: /home/open/cvs/xenocara/app/cwm/cwm.1,v
retrieving revision 1.53
diff -u -p -r1.53 cwm.1
--- cwm.1   21 Aug 2015 16:52:37 -  1.53
+++ cwm.1   6 Nov 2015 17:39:33 -
@@ -224,8 +224,8 @@ Menus are recalled by clicking the mouse
 .Pp
 .Bl -tag -width Ds -offset indent -compact
 .It Ic M1
-Show list of currently hidden windows.
-Selecting an item will unhide that window.
+Show the list of windows.
+Selecting an item will unhide, if nessecary, and warp to that window.
 .It Ic M2
 Show list of currently defined groups.
 Selecting an item will hide/unhide that group.
Index: mousefunc.c
===
RCS file: /home/open/cvs/xenocara/app/cwm/mousefunc.c,v
retrieving revision 1.98
diff -u -p -r1.98 mousefunc.c
--- mousefunc.c 21 Aug 2015 16:14:39 -  1.98
+++ mousefunc.c 6 Nov 2015 17:21:08 -
@@ -207,15 +207,14 @@ mousefunc_menu_unhide(struct client_ctx 
 
TAILQ_INIT(&menuq);
TAILQ_FOREACH(cc, &sc->clientq, entry) {
-   if (cc->flags & CLIENT_HIDDEN) {
-   menuq_add(&menuq, cc, NULL);
-   }
+   menuq_add(&menuq, cc, NULL);
}
 
if ((mi = menu_filter(sc, &menuq, NULL, NULL, CWM_MENU_LIST,
NULL, search_print_client)) != NULL) {
cc = (struct client_ctx *)mi->ctx;
-   client_unhide(cc);
+   if (cc->flags & CLIENT_HIDDEN)
+   client_unhide(cc);
if (old_cc != NULL)
client_ptrsave(old_cc);
client_ptrwarp(cc);



Re: more utf8 less ebcdic

2015-11-06 Thread Nicholas Marriott
ok nicm

The no_error argument to icharset() is now unused and could go too.




On Fri, Nov 06, 2015 at 11:47:46AM -0500, Ted Unangst wrote:
> Ted Unangst wrote:
> > Having to define LESSCHARSET to print the special characters doesn't seem 
> > that
> > useful. It doesn't do translation. So setting it to ebcdic isn't going to
> > magically make such files appear correctly in my xterm.
> > 
> > There seem to be two possibilities:
> > 1. You have LESSCHARSET and LC_CTYPE set to the same thing. Things work.
> > 2. They are different. Things will not work.
> > 
> > Removing the possibility that they are different would seem to be an
> > improvement.
> 
> Oops, that was the big bomb diff. We want to keep the nl_langinfo and some
> charset support. Just remove the environment variable and pare down some of
> the stranger charsets.
> 
> Index: charset.c
> ===
> RCS file: /cvs/src/usr.bin/less/charset.c,v
> retrieving revision 1.14
> diff -u -p -r1.14 charset.c
> --- charset.c 6 Nov 2015 16:20:37 -   1.14
> +++ charset.c 6 Nov 2015 16:37:42 -
> @@ -35,24 +35,6 @@ struct charset {
>   /* BEGIN CSTYLED */
>   { "ascii",  NULL,   "8bcccbcc18b95.b" },
>   { "utf-8",  &utf_mode,   "8bcccbcc18b95.b126.bb" },
> - { "iso8859",NULL,   "8bcccbcc18b95.33b." },
> - { "latin3", NULL,   
> "8bcccbcc18b95.33b5.b8.b15.b4.b12.b18.b12.b." },
> - { "arabic", NULL,   
> "8bcccbcc18b95.33b.3b.7b2.13b.3b.b26.5b19.b" },
> - { "greek",  NULL,   "8bcccbcc18b95.33b4.2b4.b3.b35.b44.b" },
> - { "greek2005",  NULL,   "8bcccbcc18b95.33b14.b35.b44.b" },
> - { "hebrew", NULL,   "8bcccbcc18b95.33b.b29.32b28.2b2.b" },
> - { "koi8-r", NULL,   "8bcccbcc18b95.b." },
> - { "KOI8-T", NULL,   
> "8bcccbcc18b95.b8.b6.b8.b.b.5b7.3b4.b4.b3.b.b.3b." },
> - { "georgianps", NULL,   "8bcccbcc18b95.3b11.4b12.2b." },
> - { "tcvn",   NULL,   "b..b...bcccbccbbb7.8b95.b48.5b." },
> - { "TIS-620",NULL,   "8bcccbcc18b95.b.4b.11b7.8b." },
> - { "next",   NULL,   "8bcccbcc18b95.bb125.bb" },
> - { "dos",NULL,   "8bcccbcc12bc5b95.b." },
> - { "windows-1251",   NULL,   "8bcccbcc12bc5b95.b24.b." },
> - { "windows-1252",   NULL,   "8bcccbcc12bc5b95.b.b11.b.2b12.b." },
> - { "windows-1255",   NULL,   "8bcccbcc12bc5b95.b.b8.b.5b9.b.4b." },
> - { "ebcdic", NULL,   
> "5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b." 
> },
> - { "IBM-1047",   NULL,   
> "4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc191.b" },
>   { NULL, NULL, NULL }
>   /* END CSTYLED */
>  };
> @@ -69,43 +51,6 @@ struct cs_alias {
>   { "US-ASCII",   "ascii" },
>   { "646","ascii" },
>   { "C",  "ascii" },
> - { "latin1", "iso8859" },
> - { "ISO-8859-1", "iso8859" },
> - { "latin9", "iso8859" },
> - { "ISO-8859-15","iso8859" },
> - { "latin2", "iso8859" },
> - { "ISO-8859-2", "iso8859" },
> - { "ISO-8859-3", "latin3" },
> - { "latin4", "iso8859" },
> - { "ISO-8859-4", "iso8859" },
> - { "cyrillic",   "iso8859" },
> - { "ISO-8859-5", "iso8859" },
> - { "ISO-8859-6", "arabic" },
> - { "ISO-8859-7", "greek" },
> - { "IBM9005","greek2005" },
> - { "ISO-8859-8", "hebrew" },
> - { "latin5", "iso8859" },
> - { "ISO-8859-9", "iso8859" },
> - { "latin6", "iso8859" },
> - { "ISO-8859-10","iso8859" },
> - { "latin7", "iso8859" },
> - { "ISO-8859-13","iso8859" },
> - { "latin8", "iso8859" },
> - { "ISO-8859-14","iso8859" },
> - { "latin10","iso8859" },
> - { "ISO-8859-16","iso8859" },
> - { "IBM437", "dos" },
> - { "EBCDIC-US",  "ebcdic" },
> - { "IBM1047","IBM-1047" },
> - { "KOI8-R", "koi8-r" },
> - { "KOI8-U", "koi8-r" },
> - { "GEORGIAN-PS","georgianps" },
> - { "TCVN5712-1", "tcvn" },
> - { "NEXTSTEP",   "next" },
> - { "windows","windows-1252" }, /* backward compatibility */
> - { "CP1251", "windows-1251" },
> - { "CP1252", "windows-1252" },
> - { "CP1255", "windows-1255" },
>   { NULL, NULL }
>  };
>  
> @@ -341,13 +286,6 @@ static void
>  set_charset(void)
>  {
>   char *s;
> -
> - /*
> -  * See if environment variable LESSCHARSET is defined.
> -  */
> - s = lgetenv("LESSCHARSET");
> - if (icharset(s, 0))
> - return;
>  
>

Re: more utf8 less ebcdic

2015-11-06 Thread Ted Unangst
Ted Unangst wrote:
> Having to define LESSCHARSET to print the special characters doesn't seem that
> useful. It doesn't do translation. So setting it to ebcdic isn't going to
> magically make such files appear correctly in my xterm.
> 
> There seem to be two possibilities:
> 1. You have LESSCHARSET and LC_CTYPE set to the same thing. Things work.
> 2. They are different. Things will not work.
> 
> Removing the possibility that they are different would seem to be an
> improvement.

Oops, that was the big bomb diff. We want to keep the nl_langinfo and some
charset support. Just remove the environment variable and pare down some of
the stranger charsets.

Index: charset.c
===
RCS file: /cvs/src/usr.bin/less/charset.c,v
retrieving revision 1.14
diff -u -p -r1.14 charset.c
--- charset.c   6 Nov 2015 16:20:37 -   1.14
+++ charset.c   6 Nov 2015 16:37:42 -
@@ -35,24 +35,6 @@ struct charset {
/* BEGIN CSTYLED */
{ "ascii",  NULL,   "8bcccbcc18b95.b" },
{ "utf-8",  &utf_mode,   "8bcccbcc18b95.b126.bb" },
-   { "iso8859",NULL,   "8bcccbcc18b95.33b." },
-   { "latin3", NULL,   
"8bcccbcc18b95.33b5.b8.b15.b4.b12.b18.b12.b." },
-   { "arabic", NULL,   
"8bcccbcc18b95.33b.3b.7b2.13b.3b.b26.5b19.b" },
-   { "greek",  NULL,   "8bcccbcc18b95.33b4.2b4.b3.b35.b44.b" },
-   { "greek2005",  NULL,   "8bcccbcc18b95.33b14.b35.b44.b" },
-   { "hebrew", NULL,   "8bcccbcc18b95.33b.b29.32b28.2b2.b" },
-   { "koi8-r", NULL,   "8bcccbcc18b95.b." },
-   { "KOI8-T", NULL,   
"8bcccbcc18b95.b8.b6.b8.b.b.5b7.3b4.b4.b3.b.b.3b." },
-   { "georgianps", NULL,   "8bcccbcc18b95.3b11.4b12.2b." },
-   { "tcvn",   NULL,   "b..b...bcccbccbbb7.8b95.b48.5b." },
-   { "TIS-620",NULL,   "8bcccbcc18b95.b.4b.11b7.8b." },
-   { "next",   NULL,   "8bcccbcc18b95.bb125.bb" },
-   { "dos",NULL,   "8bcccbcc12bc5b95.b." },
-   { "windows-1251",   NULL,   "8bcccbcc12bc5b95.b24.b." },
-   { "windows-1252",   NULL,   "8bcccbcc12bc5b95.b.b11.b.2b12.b." },
-   { "windows-1255",   NULL,   "8bcccbcc12bc5b95.b.b8.b.5b9.b.4b." },
-   { "ebcdic", NULL,   
"5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b." },
-   { "IBM-1047",   NULL,   
"4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc191.b" },
{ NULL, NULL, NULL }
/* END CSTYLED */
 };
@@ -69,43 +51,6 @@ struct cs_alias {
{ "US-ASCII",   "ascii" },
{ "646","ascii" },
{ "C",  "ascii" },
-   { "latin1", "iso8859" },
-   { "ISO-8859-1", "iso8859" },
-   { "latin9", "iso8859" },
-   { "ISO-8859-15","iso8859" },
-   { "latin2", "iso8859" },
-   { "ISO-8859-2", "iso8859" },
-   { "ISO-8859-3", "latin3" },
-   { "latin4", "iso8859" },
-   { "ISO-8859-4", "iso8859" },
-   { "cyrillic",   "iso8859" },
-   { "ISO-8859-5", "iso8859" },
-   { "ISO-8859-6", "arabic" },
-   { "ISO-8859-7", "greek" },
-   { "IBM9005","greek2005" },
-   { "ISO-8859-8", "hebrew" },
-   { "latin5", "iso8859" },
-   { "ISO-8859-9", "iso8859" },
-   { "latin6", "iso8859" },
-   { "ISO-8859-10","iso8859" },
-   { "latin7", "iso8859" },
-   { "ISO-8859-13","iso8859" },
-   { "latin8", "iso8859" },
-   { "ISO-8859-14","iso8859" },
-   { "latin10","iso8859" },
-   { "ISO-8859-16","iso8859" },
-   { "IBM437", "dos" },
-   { "EBCDIC-US",  "ebcdic" },
-   { "IBM1047","IBM-1047" },
-   { "KOI8-R", "koi8-r" },
-   { "KOI8-U", "koi8-r" },
-   { "GEORGIAN-PS","georgianps" },
-   { "TCVN5712-1", "tcvn" },
-   { "NEXTSTEP",   "next" },
-   { "windows","windows-1252" }, /* backward compatibility */
-   { "CP1251", "windows-1251" },
-   { "CP1252", "windows-1252" },
-   { "CP1255", "windows-1255" },
{ NULL, NULL }
 };
 
@@ -341,13 +286,6 @@ static void
 set_charset(void)
 {
char *s;
-
-   /*
-* See if environment variable LESSCHARSET is defined.
-*/
-   s = lgetenv("LESSCHARSET");
-   if (icharset(s, 0))
-   return;
 
/*
 * Try using the codeset name as the charset name.



more utf8 less ebcdic

2015-11-06 Thread Ted Unangst
Having to define LESSCHARSET to print the special characters doesn't seem that
useful. It doesn't do translation. So setting it to ebcdic isn't going to
magically make such files appear correctly in my xterm.

There seem to be two possibilities:
1. You have LESSCHARSET and LC_CTYPE set to the same thing. Things work.
2. They are different. Things will not work.

Removing the possibility that they are different would seem to be an
improvement.


Index: charset.c
===
RCS file: /cvs/src/usr.bin/less/charset.c,v
retrieving revision 1.14
diff -u -p -r1.14 charset.c
--- charset.c   6 Nov 2015 16:20:37 -   1.14
+++ charset.c   6 Nov 2015 16:30:10 -
@@ -23,92 +23,6 @@
 
 int utf_mode = 0;
 
-/*
- * Predefined character sets,
- * selected by the LESSCHARSET environment variable.
- */
-struct charset {
-   char *name;
-   int *p_flag;
-   char *desc;
-} charsets[] = {
-   /* BEGIN CSTYLED */
-   { "ascii",  NULL,   "8bcccbcc18b95.b" },
-   { "utf-8",  &utf_mode,   "8bcccbcc18b95.b126.bb" },
-   { "iso8859",NULL,   "8bcccbcc18b95.33b." },
-   { "latin3", NULL,   
"8bcccbcc18b95.33b5.b8.b15.b4.b12.b18.b12.b." },
-   { "arabic", NULL,   
"8bcccbcc18b95.33b.3b.7b2.13b.3b.b26.5b19.b" },
-   { "greek",  NULL,   "8bcccbcc18b95.33b4.2b4.b3.b35.b44.b" },
-   { "greek2005",  NULL,   "8bcccbcc18b95.33b14.b35.b44.b" },
-   { "hebrew", NULL,   "8bcccbcc18b95.33b.b29.32b28.2b2.b" },
-   { "koi8-r", NULL,   "8bcccbcc18b95.b." },
-   { "KOI8-T", NULL,   
"8bcccbcc18b95.b8.b6.b8.b.b.5b7.3b4.b4.b3.b.b.3b." },
-   { "georgianps", NULL,   "8bcccbcc18b95.3b11.4b12.2b." },
-   { "tcvn",   NULL,   "b..b...bcccbccbbb7.8b95.b48.5b." },
-   { "TIS-620",NULL,   "8bcccbcc18b95.b.4b.11b7.8b." },
-   { "next",   NULL,   "8bcccbcc18b95.bb125.bb" },
-   { "dos",NULL,   "8bcccbcc12bc5b95.b." },
-   { "windows-1251",   NULL,   "8bcccbcc12bc5b95.b24.b." },
-   { "windows-1252",   NULL,   "8bcccbcc12bc5b95.b.b11.b.2b12.b." },
-   { "windows-1255",   NULL,   "8bcccbcc12bc5b95.b.b8.b.5b9.b.4b." },
-   { "ebcdic", NULL,   
"5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b." },
-   { "IBM-1047",   NULL,   
"4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc191.b" },
-   { NULL, NULL, NULL }
-   /* END CSTYLED */
-};
-
-/*
- * Support "locale charmap"/nl_langinfo(CODESET) values, as well as others.
- */
-struct cs_alias {
-   char *name;
-   char *oname;
-} cs_aliases[] = {
-   { "UTF-8",  "utf-8" },
-   { "ANSI_X3.4-1968", "ascii" },
-   { "US-ASCII",   "ascii" },
-   { "646","ascii" },
-   { "C",  "ascii" },
-   { "latin1", "iso8859" },
-   { "ISO-8859-1", "iso8859" },
-   { "latin9", "iso8859" },
-   { "ISO-8859-15","iso8859" },
-   { "latin2", "iso8859" },
-   { "ISO-8859-2", "iso8859" },
-   { "ISO-8859-3", "latin3" },
-   { "latin4", "iso8859" },
-   { "ISO-8859-4", "iso8859" },
-   { "cyrillic",   "iso8859" },
-   { "ISO-8859-5", "iso8859" },
-   { "ISO-8859-6", "arabic" },
-   { "ISO-8859-7", "greek" },
-   { "IBM9005","greek2005" },
-   { "ISO-8859-8", "hebrew" },
-   { "latin5", "iso8859" },
-   { "ISO-8859-9", "iso8859" },
-   { "latin6", "iso8859" },
-   { "ISO-8859-10","iso8859" },
-   { "latin7", "iso8859" },
-   { "ISO-8859-13","iso8859" },
-   { "latin8", "iso8859" },
-   { "ISO-8859-14","iso8859" },
-   { "latin10","iso8859" },
-   { "ISO-8859-16","iso8859" },
-   { "IBM437", "dos" },
-   { "EBCDIC-US",  "ebcdic" },
-   { "IBM1047","IBM-1047" },
-   { "KOI8-R", "koi8-r" },
-   { "KOI8-U", "koi8-r" },
-   { "GEORGIAN-PS","georgianps" },
-   { "TCVN5712-1", "tcvn" },
-   { "NEXTSTEP",   "next" },
-   { "windows","windows-1252" }, /* backward compatibility */
-   { "CP1251", "windows-1251" },
-   { "CP1252", "windows-1252" },
-   { "CP1255", "windows-1255" },
-   { NULL, NULL }
-};
-
 #defineIS_BINARY_CHAR  01
 #defineIS_CONTROL_CHAR 02
 
@@ -119,105 +33,6 @@ int binattr = AT_STANDOUT;
 
 
 /*
- * Define a charset, given a description string.
- * The string consists of 256 letters,
- * one for each character in the charset.
- * If the 

Re: less less chardef

2015-11-06 Thread Nicholas Marriott
yes please... ok nicm


On Fri, Nov 06, 2015 at 10:18:20AM -0500, Ted Unangst wrote:
> This removes the "rarely" used LESSCHARDEF env. The next diff will be for
> LESSCHARSET, but I'm content to ax one branch at a time.
> 
> 
> Index: charset.c
> ===
> RCS file: /cvs/src/usr.bin/less/charset.c,v
> retrieving revision 1.12
> diff -u -p -r1.12 charset.c
> --- charset.c 5 Nov 2015 22:18:27 -   1.12
> +++ charset.c 6 Nov 2015 15:17:18 -
> @@ -352,15 +352,6 @@ set_charset(void)
>   return;
>  
>   /*
> -  * LESSCHARSET is not defined: try LESSCHARDEF.
> -  */
> - s = lgetenv("LESSCHARDEF");
> - if (s != NULL && *s != '\0') {
> - ichardef(s);
> - return;
> - }
> -
> - /*
>* Try using the codeset name as the charset name.
>*/
>   s = nl_langinfo(CODESET);
> Index: less.1
> ===
> RCS file: /cvs/src/usr.bin/less/less.1,v
> retrieving revision 1.45
> diff -u -p -r1.45 less.1
> --- less.123 Nov 2014 09:56:32 -  1.45
> +++ less.16 Nov 2015 15:17:18 -
> @@ -1482,40 +1482,7 @@ It is the only character set that suppor
>  Selects a character set appropriate for Microsoft Windows (cp 1251).
>  .El
>  .Pp
> -In rare cases, it may be desired to tailor
> -.Nm
> -to use a character set other than the ones definable by LESSCHARSET.
> -In this case, the environment variable
> -.Ev LESSCHARDEF
> -can be used to define a character set.
> -It should be set to a string where each character in the string represents
> -one character in the character set.
> -The character "." is used for a normal character, "c" for control,
> -and "b" for binary.
> -A decimal number may be used for repetition.
> -For example, "bccc4b." would mean character 0 is binary,
> -1, 2 and 3 are control, 4, 5, 6 and 7 are binary, and 8 is normal.
> -All characters after the last are taken to be the same as the last,
> -so characters 9 through 255 would be normal.
> -(This is an example, and does not necessarily
> -represent any real character set.)
> -.Pp
> -This table shows the value of LESSCHARDEF which is equivalent
> -to each of the possible values for LESSCHARSET:
> -.Bd -literal -offset indent
> -ascii8bcccbcc18b95.b
> -dos  8bcccbcc12bc5b95.b.
> -ebcdic   5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b
> - 9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b.
> -IBM-1047 4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc
> - 191.b
> -iso8859  8bcccbcc18b95.33b.
> -koi8-r   8bcccbcc18b95.b128.
> -latin1   8bcccbcc18b95.33b.
> -next 8bcccbcc18b95.bb125.bb
> -.Ed
> -.Pp
> -If neither LESSCHARSET nor LESSCHARDEF is set,
> +If neither LESSCHARSET is not set,
>  but any of the strings "UTF-8", "UTF8", "utf-8" or "utf8" is found in the
>  .Ev LC_ALL , LC_CTYPE
>  or
> @@ -1946,8 +1913,6 @@ end character in an ANSI color escape se
>  (default "0123456789;[?!"'#%()*+\ ").
>  .It Ev LESSBINFMT
>  Format for displaying non-printable, non-control characters.
> -.It Ev LESSCHARDEF
> -Defines a character set.
>  .It Ev LESSCHARSET
>  Selects a predefined character set.
>  .It Ev LESSCLOSE
> 



less less chardef

2015-11-06 Thread Ted Unangst
This removes the "rarely" used LESSCHARDEF env. The next diff will be for
LESSCHARSET, but I'm content to ax one branch at a time.


Index: charset.c
===
RCS file: /cvs/src/usr.bin/less/charset.c,v
retrieving revision 1.12
diff -u -p -r1.12 charset.c
--- charset.c   5 Nov 2015 22:18:27 -   1.12
+++ charset.c   6 Nov 2015 15:17:18 -
@@ -352,15 +352,6 @@ set_charset(void)
return;
 
/*
-* LESSCHARSET is not defined: try LESSCHARDEF.
-*/
-   s = lgetenv("LESSCHARDEF");
-   if (s != NULL && *s != '\0') {
-   ichardef(s);
-   return;
-   }
-
-   /*
 * Try using the codeset name as the charset name.
 */
s = nl_langinfo(CODESET);
Index: less.1
===
RCS file: /cvs/src/usr.bin/less/less.1,v
retrieving revision 1.45
diff -u -p -r1.45 less.1
--- less.1  23 Nov 2014 09:56:32 -  1.45
+++ less.1  6 Nov 2015 15:17:18 -
@@ -1482,40 +1482,7 @@ It is the only character set that suppor
 Selects a character set appropriate for Microsoft Windows (cp 1251).
 .El
 .Pp
-In rare cases, it may be desired to tailor
-.Nm
-to use a character set other than the ones definable by LESSCHARSET.
-In this case, the environment variable
-.Ev LESSCHARDEF
-can be used to define a character set.
-It should be set to a string where each character in the string represents
-one character in the character set.
-The character "." is used for a normal character, "c" for control,
-and "b" for binary.
-A decimal number may be used for repetition.
-For example, "bccc4b." would mean character 0 is binary,
-1, 2 and 3 are control, 4, 5, 6 and 7 are binary, and 8 is normal.
-All characters after the last are taken to be the same as the last,
-so characters 9 through 255 would be normal.
-(This is an example, and does not necessarily
-represent any real character set.)
-.Pp
-This table shows the value of LESSCHARDEF which is equivalent
-to each of the possible values for LESSCHARSET:
-.Bd -literal -offset indent
-ascii  8bcccbcc18b95.b
-dos8bcccbcc12bc5b95.b.
-ebcdic 5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b
-   9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b.
-IBM-1047   4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc
-   191.b
-iso88598bcccbcc18b95.33b.
-koi8-r 8bcccbcc18b95.b128.
-latin1 8bcccbcc18b95.33b.
-next   8bcccbcc18b95.bb125.bb
-.Ed
-.Pp
-If neither LESSCHARSET nor LESSCHARDEF is set,
+If neither LESSCHARSET is not set,
 but any of the strings "UTF-8", "UTF8", "utf-8" or "utf8" is found in the
 .Ev LC_ALL , LC_CTYPE
 or
@@ -1946,8 +1913,6 @@ end character in an ANSI color escape se
 (default "0123456789;[?!"'#%()*+\ ").
 .It Ev LESSBINFMT
 Format for displaying non-printable, non-control characters.
-.It Ev LESSCHARDEF
-Defines a character set.
 .It Ev LESSCHARSET
 Selects a predefined character set.
 .It Ev LESSCLOSE



Re: execless wump

2015-11-06 Thread Ted Unangst
Christian Weisgerber wrote:
> "Ted Unangst":
> 
> > here's a nickel kid, get a terminal with scrollback...
> 
> We could have just deleted less(1)!
> I think you are going overboard here.  If you really want to delete
> the exec, at least replace it with a minimal built-in pager like
> ddb's.

Well, besides the prevalence of scrollback, are people playing wump on
machines with only a single terminal?

If the help is really that useful, a better place for it would be either the
man page, to print a pointer to the help file on disk. Then the user can view
the instructions at the same time as playing the game. Or print them out. Or
whatever. But printing inline help each time you start the game seems like a
holdover from the era of sitting in the comp lab basement at a vt100.



patch: top cpu stats default display

2015-11-06 Thread Benny Lofgren
Hi tech@,

I want to suggest a small convenience (for me at least) change to top(1):

- Always start with combined cpu stats view (one line)

Supporting changes:
- Invert behaviour of "top -1" accordingly
- Remove then unnecessary "if cpus > 8 then combined_view = 1"
- Adjust man page accordingly
- Correct built-in help page accordingly


Rationale:

I don't know about the rest of you, but personally I almost always want
to see the combined CPU statistics on top of top's (pun not intended)
display page.

If there's a process stuck in a loop or something I might want to break
the display out to show separate cores but otherwise I prefer to use
maximum real estate for the process list.


I know there's an "if more than eight processors, then start with
combined cpu" clause, but my muscle memory likes a consistent behaviour.
Not that running "top -1" is a big nuisance, but still...

Besides, the number eight feels kind of arbitrary to me. I mean, if the
default behaviour is going to be dynamically decided anyway, why not
base it on for example the number of available screen lines?


If I'm not the only one who would like this, here's a diff.


Regards,

/Benny



(I hope my Thunderbird doesn't mangle the diff, a couple of lines are
>80 characters.)


Index: display.c
===
RCS file: /cvs/src/usr.bin/top/display.c,v
retrieving revision 1.50
diff -u -p -r1.50 display.c
--- display.c   26 Oct 2015 12:44:22 -  1.50
+++ display.c   6 Nov 2015 13:28:55 -
@@ -804,7 +804,7 @@ show_help(void)
"^L   - redraw screen\n"
"  - update screen\n"
"+- reset any g, p, or u filters\n"
-   "1- display CPU statistics on a single line\n"
+   "1- toggle display of combined (one line) or
per-CPU statistics\n"
"C- toggle the display of command line arguments\n"
"d count  - show `count' displays, then exit\n"
"e- list errors generated by last \"kill\" or
\"renice\" command\n"
Index: top.1
===
RCS file: /cvs/src/usr.bin/top/top.1,v
retrieving revision 1.66
diff -u -p -r1.66 top.1
--- top.1   6 May 2015 07:53:29 -   1.66
+++ top.1   6 Nov 2015 13:28:55 -
@@ -75,10 +75,9 @@ terminal.
 The options are as follows:
 .Bl -tag -width Ds
 .It Fl 1
-Display combined CPU statistics for all processors on a single line
-instead of one line per CPU.
-If there are more than 8 CPUs detected in the system this option
-is automatically enabled.
+Display CPU usage statistics split on one line per processor.
+Default is to display combined statistics for all processors
+on a single line.
 .It Fl b
 Use
 .Em batch
Index: top.c
===
RCS file: /cvs/src/usr.bin/top/top.c,v
retrieving revision 1.88
diff -u -p -r1.88 top.c
--- top.c   5 Nov 2015 17:17:13 -   1.88
+++ top.c   6 Nov 2015 13:28:55 -
@@ -83,7 +83,7 @@ int old_system = No;
 int old_threads = No;
 int show_args = No;
 pid_t hlpid = -1;
-int combine_cpus = 0;
+int combine_cpus = 1;

 #if Default_TOPN == Infinity
 char topn_specified = No;
@@ -139,7 +139,7 @@ parseargs(int ac, char **av)
while ((i = getopt(ac, av, "1SHICbinqus:d:p:U:o:g:")) != -1) {
switch (i) {
case '1':
-   combine_cpus = 1;
+   combine_cpus = !combine_cpus;
break;
case 'C':
show_args = Yes;
@@ -253,9 +253,6 @@ parseargs(int ac, char **av)
i = getncpu();
if (i == -1)
err(1, NULL);
-
-   if (i > 8)
-   combine_cpus = 1;

/* get count of top processes to display (if any) */
if (optind < ac) {



Re: chgrp(1) & chown(8): mark -h and -R as mutually exclusive

2015-11-06 Thread Ingo Schwarze
Hi Frederic,

Frederic Nowak wrote on Fri, Nov 06, 2015 at 08:58:14AM +0100:
> On 05 November 2015 at 19:02 Ingo Schwarze  wrote:

>>   http://mdocml.bsd.lv/mdoc/

> Thanks, I hadn't seen that resource before. Looks very interesting!
> Would it make sense to include a link, e.g. in the description section
> of mdoc(7)?

Maybe at some point, probably not yet, it is still very incomplete.
I only recently started mentioning it in public at all.

> By the way, is there a place where I could send patches for the
> extended documentation etc?

For

  http://mdocml.bsd.lv/mdoc/

for now, just to me, certainly not to .

> I only found a spelling mistake so far
> (http://manpages.bsd.lv/toc.html "1. Chapter: Commnds"), but just in
> case I find something else while reading it.

Wait, that's not the same thing, that's Kristaps' tutorial,
which is barely maintained at this point.

For

  http://manpages.bsd.lv/

probably  is the best address.

Yours,
  Ingo



Re: execless wump

2015-11-06 Thread Christian Weisgerber
"Ted Unangst":

> here's a nickel kid, get a terminal with scrollback...

We could have just deleted less(1)!
I think you are going overboard here.  If you really want to delete
the exec, at least replace it with a minimal built-in pager like
ddb's.

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



remove IF_PREPEND in src/sys/dev/pci, was Re: IFQ_PREPEND

2015-11-06 Thread David Gwynne
On Wed, Nov 04, 2015 at 08:18:48AM +0100, Martin Pieuchot wrote:
> On 04/11/15(Wed) 10:39, David Gwynne wrote:
> > im working on making the interface send queue mpsafe.
> > 
> > part of that involced deprecating the IFQ_POLL api because it allows the 
> > caller to get a reference an mbuf that is still on the send queue. this is 
> > dangerous if another cpu tries to manipulate the send queue. instead code 
> > should call IFQ_DEQUEUE, which takes it off the queue for the driver to use.
> > 
> > however, blindly changing code from IFQ_POLL to IFQ_DEQUEUE will
> > cause unwanted packet loss when encapsulation fails in some cases,
> > such as when the tx ring is already full. to cope, the easiest
> > solution is to requeue the packet so the next call to the start
> > routine can try fitting it on the ring again.
> > 
> > this introduces IFQ_PREPEND (cause we currently have IF_PREPEND)
> > and works on top of both hfsc and priq because i added hfsc_requeue
> > a while back.
> > 
> > this also converts uses of IF_PREPEND in drivers to IFQ_PREPEND.
> > this improves the situation a bit if people have decided to use
> > hfsc on these interfaces.

ok, so after talking to kenjiro cho about the problems with IFQ_PREPEND
and arbitrary queuing disciplines, im taking a step back while
thinking about how to approach the send queue stuff for a bit.
however, deprecating IF_PREPEND is still necessary.

this tweaks the relevant drivers to not need IF_PREPEND. note that
these are non-trivial changes, so i would like some review and maybe
some actual testing? especially on vr, im sure there are a lot of
users.

most of the changes are just shuffling conditionals around, but vr
also includes a change to use m_defrag. im not sure that is enough
to satisfy the alignment requirements the code discusses, so testing
is necessary.  and at least one of age, alc, or ale.

ok?

Index: if_age.c
===
RCS file: /cvs/src/sys/dev/pci/if_age.c,v
retrieving revision 1.29
diff -u -p -r1.29 if_age.c
--- if_age.c25 Oct 2015 13:04:28 -  1.29
+++ if_age.c6 Nov 2015 11:27:04 -
@@ -89,7 +89,7 @@ void  age_dma_free(struct age_softc *);
 void   age_get_macaddr(struct age_softc *);
 void   age_phy_reset(struct age_softc *);
 
-intage_encap(struct age_softc *, struct mbuf **);
+intage_encap(struct age_softc *, struct mbuf *);
 void   age_init_tx_ring(struct age_softc *);
 intage_init_rx_ring(struct age_softc *);
 void   age_init_rr_ring(struct age_softc *);
@@ -957,7 +957,7 @@ void
 age_start(struct ifnet *ifp)
 {
 struct age_softc *sc = ifp->if_softc;
-struct mbuf *m_head;
+struct mbuf *m;
int enq;
 
if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
@@ -969,8 +969,14 @@ age_start(struct ifnet *ifp)
 
enq = 0;
for (;;) {
-   IFQ_DEQUEUE(&ifp->if_snd, m_head);
-   if (m_head == NULL)
+   if (sc->age_cdata.age_tx_cnt + AGE_MAXTXSEGS >=
+   AGE_TX_RING_CNT - 2) {
+   ifp->if_flags |= IFF_OACTIVE;
+   break;
+   }
+
+   IFQ_DEQUEUE(&ifp->if_snd, m);
+   if (m == NULL)
break;
 
/*
@@ -978,14 +984,9 @@ age_start(struct ifnet *ifp)
 * don't have room, set the OACTIVE flag and wait
 * for the NIC to drain the ring.
 */
-   if (age_encap(sc, &m_head)) {
-   if (m_head == NULL)
-   ifp->if_oerrors++;
-   else {
-   IF_PREPEND(&ifp->if_snd, m_head);
-   ifp->if_flags |= IFF_OACTIVE;
-   }
-   break;
+   if (age_encap(sc, m) != 0) {
+   ifp->if_oerrors++;
+   continue;
}
enq = 1;
 
@@ -995,7 +996,7 @@ age_start(struct ifnet *ifp)
 * to him.
 */
if (ifp->if_bpf != NULL)
-   bpf_mtap_ether(ifp->if_bpf, m_head, BPF_DIRECTION_OUT);
+   bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_OUT);
 #endif
}
 
@@ -1115,16 +1116,14 @@ age_mac_config(struct age_softc *sc)
 }
 
 int
-age_encap(struct age_softc *sc, struct mbuf **m_head)
+age_encap(struct age_softc *sc, struct mbuf *m)
 {
struct age_txdesc *txd, *txd_last;
struct tx_desc *desc;
-   struct mbuf *m;
bus_dmamap_t map;
uint32_t cflags, poff, vtag;
int error, i, prod;
 
-   m = *m_head;
cflags = vtag = 0;
poff = 0;
 
@@ -1133,27 +1132,20 @@ age_encap(struct age_softc *sc, struct m
txd_last = txd;
map = txd->tx_dmamap;
 
-   error = bus_dmamap_load_mbuf(sc->sc_dmat, map, *m_head, BUS_DMA_NOWAIT);
+   error = bus_

Re: fix CRYPTO_chacha_20() on BE32 platforms

2015-11-06 Thread Reyk Floeter
Hi,

On Fri, Nov 06, 2015 at 05:39:03AM +, Miod Vallat wrote:
> Running regress/lib/libcrypto/aead fails on big-endian platforms without
> the following diff, for the ``Test vector from RFC7539 2.8.2'' test, due
> to 64-bit counters being truncated to size_t.
> 

Yes, the counter should be unsigned 64bit.

OK reyk@

I can only see one other *int64_t in LibreSSL's API, should it be
unsigned long long?  Or is it OK to start using C99 types in the API? (yes!)

The comment "converting size_t to u8" should also be updated:

---snip---
void
CRYPTO_chacha_20(unsigned char *out, const unsigned char *in, size_t len,
const unsigned char key[32], const unsigned char iv[8], size_t counter)
{
struct chacha_ctx ctx;

/*
 * chacha_ivsetup expects the counter to be in u8. Rather than
 * converting size_t to u8 and then back again, pass a counter of
 * NULL and manually assign it afterwards.
 */
chacha_keysetup(&ctx, key, 256);
chacha_ivsetup(&ctx, iv, NULL);
if (counter != 0) {
ctx.input[12] = (uint32_t)counter;
ctx.input[13] = (uint32_t)(((uint64_t)counter) >> 32);
}

chacha_encrypt_bytes(&ctx, in, out, (uint32_t)len);
}
---snap---

Reyk

> Index: chacha/chacha.c
> ===
> RCS file: /OpenBSD/src/lib/libssl/src/crypto/chacha/chacha.c,v
> retrieving revision 1.6
> diff -u -p -r1.6 chacha.c
> --- chacha/chacha.c   8 Jul 2014 14:30:23 -   1.6
> +++ chacha/chacha.c   6 Nov 2015 05:37:19 -
> @@ -57,7 +57,7 @@ ChaCha(ChaCha_ctx *ctx, unsigned char *o
>  
>  void
>  CRYPTO_chacha_20(unsigned char *out, const unsigned char *in, size_t len,
> -const unsigned char key[32], const unsigned char iv[8], size_t counter)
> +const unsigned char key[32], const unsigned char iv[8], uint64_t counter)
>  {
>   struct chacha_ctx ctx;
>  
> Index: chacha/chacha.h
> ===
> RCS file: /OpenBSD/src/lib/libssl/src/crypto/chacha/chacha.h,v
> retrieving revision 1.6
> diff -u -p -r1.6 chacha.h
> --- chacha/chacha.h   25 Jul 2014 14:04:51 -  1.6
> +++ chacha/chacha.h   6 Nov 2015 05:37:19 -
> @@ -44,7 +44,7 @@ void ChaCha(ChaCha_ctx *ctx, unsigned ch
>  size_t len);
>  
>  void CRYPTO_chacha_20(unsigned char *out, const unsigned char *in, size_t 
> len,
> -const unsigned char key[32], const unsigned char iv[8], size_t counter);
> +const unsigned char key[32], const unsigned char iv[8], uint64_t 
> counter);
>  
>  #ifdef  __cplusplus
>  }
> 

-- 



Re: chgrp(1) & chown(8): mark -h and -R as mutually exclusive

2015-11-06 Thread Frederic Nowak
Hi Ingo,

> On 05 November 2015 at 19:02 Ingo Schwarze  wrote:
> 
> 
> Hi Frederic,
> 
> Theo de Raadt wrote on Thu, Nov 05, 2015 at 10:53:55AM -0700:
> > Frederic Nowak wrote:
> 
> >> the command line arguments -h and -R for chgrp and chown are
> >> mutually
> >> exclusive. The patch below changes the markup and the usage strings
> >> to
> >> make this clearer.
> 
> Thank you for working on OpenBSD manual pages!
> 
> > I don't think it makes it clearer; it makes it more confusing.
> > 
> > The usage messages of programs are not a sufficent grammer to
> > exactly
> > describe what conflicts with what.  Taken too far, it would bewilder
> > newcomers.
> 
> For a more comprehensive explanation of why this particular patch is
> rejected, look at this style guide entry:
> 
>   http://mdocml.bsd.lv/mdoc/style/synopsis.html
> 
> Other parts of the extended mdoc(7) documentation may sometimes
> come in handy for your work as well:
> 
>   http://mdocml.bsd.lv/mdoc/
> 
> Yours,
>   Ingo

Thanks, I hadn't seen that resource before. Looks very interesting!
Would it make sense to include a link, e.g. in the description section
of mdoc(7)?

By the way, is there a place where I could send patches for the
extended documentation etc? I only found a spelling mistake so far
(http://manpages.bsd.lv/toc.html "1. Chapter: Commnds"), but just in
case I find something else while reading it.

Cheers,
Frederic

> 
> 
> > > Index: bin/chmod/chgrp.1
> > > ===
> > > RCS file: /cvs/src/bin/chmod/chgrp.1,v
> > > retrieving revision 1.16
> > > diff -u -p -r1.16 chgrp.1
> > > --- bin/chmod/chgrp.1 21 Jan 2014 22:35:44 -  1.16
> > > +++ bin/chmod/chgrp.1 5 Nov 2015 17:09:11 -
> > > @@ -40,9 +40,7 @@
> > >  .Nd change group
> > >  .Sh SYNOPSIS
> > >  .Nm chgrp
> > > -.Op Fl h
> > > -.Oo
> > > -.Fl R
> > > +.Oo Fl h | R
> > >  .Op Fl H | L | P
> > >  .Oc
> > >  .Ar group
> > > Index: bin/chmod/chmod.c
> > > ===
> > > RCS file: /cvs/src/bin/chmod/chmod.c,v
> > > retrieving revision 1.38
> > > diff -u -p -r1.38 chmod.c
> > > --- bin/chmod/chmod.c 9 Oct 2015 01:37:06 -   1.38
> > > +++ bin/chmod/chmod.c 5 Nov 2015 17:09:11 -
> > > @@ -350,11 +350,11 @@ usage(void)
> > >   __progname, ischmod ? "mode" : "flags");
> > >   else
> > >   fprintf(stderr,
> > > - "usage: %s [-h] [-R [-H | -L | -P]] %s file ...\n",
> > > + "usage: %s [-h | -R [-H | -L | -P]] %s file ...\n",
> > >   __progname, ischown ? "owner[:group]" : "group");
> > >   if (ischown)
> > >   fprintf(stderr,
> > > - "   %s [-h] [-R [-H | -L | -P]] :group file ...\n",
> > > + "   %s [-h | -R [-H | -L | -P]] :group file ...\n",
> > >   __progname);
> > >   exit(1);
> > >  }
> > > Index: bin/chmod/chown.8
> > > ===
> > > RCS file: /cvs/src/bin/chmod/chown.8,v
> > > retrieving revision 1.19
> > > diff -u -p -r1.19 chown.8
> > > --- bin/chmod/chown.8 14 Sep 2015 20:06:58 -  1.19
> > > +++ bin/chmod/chown.8 5 Nov 2015 17:09:11 -
> > > @@ -37,17 +37,13 @@
> > >  .Nd change file owner and group
> > >  .Sh SYNOPSIS
> > >  .Nm chown
> > > -.Op Fl h
> > > -.Oo
> > > -.Fl R
> > > +.Oo Fl h | R
> > >  .Op Fl H | L | P
> > >  .Oc
> > >  .Ar owner Ns Op : Ns Ar group
> > >  .Ar
> > >  .Nm chown
> > > -.Op Fl h
> > > -.Oo
> > > -.Fl R
> > > +.Oo Fl h | R
> > >  .Op Fl H | L | P
> > >  .Oc
> > >  .Pf : Ar group
>