[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bash-4.3 Official Patch 30
From: |
Ángel González |
Subject: |
Re: Bash-4.3 Official Patch 30 |
Date: |
Wed, 08 Oct 2014 00:31:24 +0200 |
Chet Ramey wrote:
> On 10/6/14, 6:16 PM, John E. Malmberg wrote:
>
> >>> Do you mean return ""; ?
> >>
> >> Yes, good catch. It doesn't make a difference: clang and gcc both accept
> >> it as written and it behaves as desired. However, I'll change it for the
> >> next version.
> >
> > Changing it to return 0 instead of '\0' would probably be more clear.
> > No need to return a pointer to a static empty string.
>
> It depends on how you want the function to work. It is nice to
> differentiate between the cases where there is no shell input line
> at all, where the index is just wrong, and the actual current input
> pointer. A "" indicates the second case better than a 0, though it's
> not perfect.
>
> Chet
Note it **is** returning NULL, not "" as it seemed implied by earlier
messages. Only verified gcc (4.9.1) behavior, but that's also what I
expected from the C code: '\0' (char) promoted to 0 (int), then to
NULL (char*)
Regards
> #include <stdio.h>
>
> char *
> foo()
> {
> return '\0';
> }
>
> int main()
> {
> printf("The value is: %p\n", foo());
> return 0;
> }
Output:
> (nil)
- Bash-4.3 Official Patch 30, Chet Ramey, 2014/10/05
- Re: Bash-4.3 Official Patch 30, Ryan Cunningham, 2014/10/05
- Re: Bash-4.3 Official Patch 30, tsugutomo . enami, 2014/10/06
- Re: Bash-4.3 Official Patch 30, Chet Ramey, 2014/10/06
- Re: Bash-4.3 Official Patch 30, John E. Malmberg, 2014/10/06
- Re: Bash-4.3 Official Patch 30, Chet Ramey, 2014/10/07
- Re: Bash-4.3 Official Patch 30,
Ángel González <=
- Re: Bash-4.3 Official Patch 30, Chet Ramey, 2014/10/07
- Re: Bash-4.3 Official Patch 30, Andreas Schwab, 2014/10/08
- Re: Bash-4.3 Official Patch 30, Chet Ramey, 2014/10/08