Re: ksh tab completion: ^_: unexpected `^'

2016-09-08 Thread Nicholas Marriott
This is incoherent and I don't see what it has to do with the issue, you
will need to provide a diff yourself.



On Thu, Sep 08, 2016 at 09:18:19AM -0400, sven falempin wrote:
> This does not include UTF8 basic character,
> 
> so if someone do  
> 
> And it want to do it again for that file ... svik , does not work.
> 
> This problem should be address in isalnum, i guess, i think some c++
> lib did it already,
> and i have a headache everytime i want to use \w in a regexp.
> 
> current $ ./a.out ??lol
> NOP
> _
> ~
> current $ ./a.out elol
> elol_
> ~
> current $ cat /tmp/foo.c
> #include 
> 
> int main(int argc, char** argv) {
>   if (isalnum(argv[1][0] )) printf("%s", argv[1]); else printf ("NOP\n");
> }
> 
> On Thu, Sep 8, 2016 at 6:08 AM, Stuart Henderson  wrote:
> > On 2016/09/08 10:45, Nicholas Marriott wrote:
> >> Yeah we probably shouldn't bother to look for commands that aren't 
> >> [A-Za-z0-9_-]:
> >
> > I don't think - is necessary, it's not a valid character for an array
> > name so it can't be used here anyway. Otherwise OK.
> >
> >> Index: edit.c
> >> ===
> >> RCS file: /cvs/src/bin/ksh/edit.c,v
> >> retrieving revision 1.56
> >> diff -u -p -r1.56 edit.c
> >> --- edit.c7 Sep 2016 04:42:31 -   1.56
> >> +++ edit.c8 Sep 2016 09:45:21 -
> >> @@ -584,9 +584,8 @@ x_try_array(const char *buf, int buflen,
> >>  int *nwords, char ***words)
> >>  {
> >>   const char *cmd, *cp;
> >> - int cmdlen, n;
> >> + int cmdlen, n, i, slen;
> >>   char *name, *s;
> >> - size_t slen;
> >>   struct tbl *v, *vp;
> >>
> >>   *nwords = 0;
> >> @@ -604,6 +603,10 @@ x_try_array(const char *buf, int buflen,
> >>   cmdlen = 0;
> >>   while (cmd + cmdlen < want && !isspace((u_char)cmd[cmdlen]))
> >>   cmdlen++;
> >> + for (i = 0; i < cmdlen; i++) {
> >> + if (!isalnum((u_char)cmd[i]) && cmd[i] != '_' && cmd[i] != 
> >> '-')
> >> + return 0;
> >> + }
> >>
> >>   /* Take a stab at argument count from here. */
> >>   n = 1;
> >>
> >>
> >> On Thu, Sep 08, 2016 at 09:43:53AM +0100, Stuart Henderson wrote:
> >> > I just ran into this which was introduced with custom completions
> >> > (I haven't setup any complete_* arrays).
> >> >
> >> > $ ag "(foo)[^_]" /u
> >> >
> >> > results in
> >
> 
> 
> 
> -- 
> -
> () ascii ribbon campaign - against html e-mail
> /\



Re: ksh tab completion: ^_: unexpected `^'

2016-09-08 Thread sven falempin
This does not include UTF8 basic character,

so if someone do  

And it want to do it again for that file ... sviňák , does not work.

This problem should be address in isalnum, i guess, i think some c++
lib did it already,
and i have a headache everytime i want to use \w in a regexp.

current $ ./a.out élol
NOP
_
~
current $ ./a.out elol
elol_
~
current $ cat /tmp/foo.c
#include 

int main(int argc, char** argv) {
  if (isalnum(argv[1][0] )) printf("%s", argv[1]); else printf ("NOP\n");
}

On Thu, Sep 8, 2016 at 6:08 AM, Stuart Henderson  wrote:
> On 2016/09/08 10:45, Nicholas Marriott wrote:
>> Yeah we probably shouldn't bother to look for commands that aren't 
>> [A-Za-z0-9_-]:
>
> I don't think - is necessary, it's not a valid character for an array
> name so it can't be used here anyway. Otherwise OK.
>
>> Index: edit.c
>> ===
>> RCS file: /cvs/src/bin/ksh/edit.c,v
>> retrieving revision 1.56
>> diff -u -p -r1.56 edit.c
>> --- edit.c7 Sep 2016 04:42:31 -   1.56
>> +++ edit.c8 Sep 2016 09:45:21 -
>> @@ -584,9 +584,8 @@ x_try_array(const char *buf, int buflen,
>>  int *nwords, char ***words)
>>  {
>>   const char *cmd, *cp;
>> - int cmdlen, n;
>> + int cmdlen, n, i, slen;
>>   char *name, *s;
>> - size_t slen;
>>   struct tbl *v, *vp;
>>
>>   *nwords = 0;
>> @@ -604,6 +603,10 @@ x_try_array(const char *buf, int buflen,
>>   cmdlen = 0;
>>   while (cmd + cmdlen < want && !isspace((u_char)cmd[cmdlen]))
>>   cmdlen++;
>> + for (i = 0; i < cmdlen; i++) {
>> + if (!isalnum((u_char)cmd[i]) && cmd[i] != '_' && cmd[i] != '-')
>> + return 0;
>> + }
>>
>>   /* Take a stab at argument count from here. */
>>   n = 1;
>>
>>
>> On Thu, Sep 08, 2016 at 09:43:53AM +0100, Stuart Henderson wrote:
>> > I just ran into this which was introduced with custom completions
>> > (I haven't setup any complete_* arrays).
>> >
>> > $ ag "(foo)[^_]" /u
>> >
>> > results in
>



-- 
-
() ascii ribbon campaign - against html e-mail
/\



Re: ksh tab completion: ^_: unexpected `^'

2016-09-08 Thread Stuart Henderson
On 2016/09/08 10:45, Nicholas Marriott wrote:
> Yeah we probably shouldn't bother to look for commands that aren't 
> [A-Za-z0-9_-]:

I don't think - is necessary, it's not a valid character for an array
name so it can't be used here anyway. Otherwise OK.

> Index: edit.c
> ===
> RCS file: /cvs/src/bin/ksh/edit.c,v
> retrieving revision 1.56
> diff -u -p -r1.56 edit.c
> --- edit.c7 Sep 2016 04:42:31 -   1.56
> +++ edit.c8 Sep 2016 09:45:21 -
> @@ -584,9 +584,8 @@ x_try_array(const char *buf, int buflen,
>  int *nwords, char ***words)
>  {
>   const char *cmd, *cp;
> - int cmdlen, n;
> + int cmdlen, n, i, slen;
>   char *name, *s;
> - size_t slen;
>   struct tbl *v, *vp;
>  
>   *nwords = 0;
> @@ -604,6 +603,10 @@ x_try_array(const char *buf, int buflen,
>   cmdlen = 0;
>   while (cmd + cmdlen < want && !isspace((u_char)cmd[cmdlen]))
>   cmdlen++;
> + for (i = 0; i < cmdlen; i++) {
> + if (!isalnum((u_char)cmd[i]) && cmd[i] != '_' && cmd[i] != '-')
> + return 0;
> + }
>  
>   /* Take a stab at argument count from here. */
>   n = 1;
> 
> 
> On Thu, Sep 08, 2016 at 09:43:53AM +0100, Stuart Henderson wrote:
> > I just ran into this which was introduced with custom completions
> > (I haven't setup any complete_* arrays).
> > 
> > $ ag "(foo)[^_]" /u
> > 
> > results in



Re: ksh tab completion: ^_: unexpected `^'

2016-09-08 Thread Nicholas Marriott
Yeah we probably shouldn't bother to look for commands that aren't 
[A-Za-z0-9_-]:

Index: edit.c
===
RCS file: /cvs/src/bin/ksh/edit.c,v
retrieving revision 1.56
diff -u -p -r1.56 edit.c
--- edit.c  7 Sep 2016 04:42:31 -   1.56
+++ edit.c  8 Sep 2016 09:45:21 -
@@ -584,9 +584,8 @@ x_try_array(const char *buf, int buflen,
 int *nwords, char ***words)
 {
const char *cmd, *cp;
-   int cmdlen, n;
+   int cmdlen, n, i, slen;
char *name, *s;
-   size_t slen;
struct tbl *v, *vp;
 
*nwords = 0;
@@ -604,6 +603,10 @@ x_try_array(const char *buf, int buflen,
cmdlen = 0;
while (cmd + cmdlen < want && !isspace((u_char)cmd[cmdlen]))
cmdlen++;
+   for (i = 0; i < cmdlen; i++) {
+   if (!isalnum((u_char)cmd[i]) && cmd[i] != '_' && cmd[i] != '-')
+   return 0;
+   }
 
/* Take a stab at argument count from here. */
n = 1;


On Thu, Sep 08, 2016 at 09:43:53AM +0100, Stuart Henderson wrote:
> I just ran into this which was introduced with custom completions
> (I haven't setup any complete_* arrays).
> 
> $ ag "(foo)[^_]" /u
> 
> results in
> 
> ksh: ^_: unexpected `^'
>