Merge pull request #789 from xexyl/1985-applin
Minor improvements to 1985/applin
This commit is contained in:
2 files changed
+20
-10
No files matched your search
+19
-9
@@ -16,20 +16,30 @@ make all
|
|||||||
./applin
|
./applin
|
||||||
```
|
```
|
||||||
|
|
||||||
NOTE: [Yusuke Endoh](/winners.html#Yusuke_Endoh) provided a patch to get this to
|
[Yusuke Endoh](/winners.html#Yusuke_Endoh) provided a patch to get this to
|
||||||
not issue crash and [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson)
|
not issue crash and [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson)
|
||||||
fixed this to work with macOS. The problem with the crash is that it
|
fixed this to work with macOS (it printed the string `H????` in a seemingly
|
||||||
destructively rewrites string literals but with `strdup()` it's safe. For macOS
|
infinite loop of printing more and more `?`s).
|
||||||
it's because there was no prototype for `execlp()` and macOS has problems with
|
|
||||||
missing prototypes for some functions (this was also seen when Cody fixed
|
|
||||||
[1984/anonymous](/1984/anonymous/anonymous.c) for macOS as well though that fix
|
|
||||||
was more complicated). Ironically this fix was discovered through linux! Thank
|
|
||||||
you Yusuke and Cody for your help!
|
|
||||||
|
|
||||||
|
The problem with the crash is that it destructively rewrites string literals but
|
||||||
|
with `strdup()` it's safe.
|
||||||
|
|
||||||
|
For macOS it's because there was no prototype for `execlp()` and macOS has
|
||||||
|
problems with missing prototypes for some functions (this was also seen when
|
||||||
|
Cody fixed [1984/anonymous](/1984/anonymous/anonymous.c) for macOS as well
|
||||||
|
though that fix was more complicated). Ironically this fix was discovered
|
||||||
|
through linux!
|
||||||
|
|
||||||
|
NOTE: originally this entry did not print a newline prior to returning to the
|
||||||
|
shell, after the output (despite having `\n` in the string - why?) but to make
|
||||||
|
it more friendly to users Cody made it print a `\n` prior to returning to the
|
||||||
|
shell.
|
||||||
|
|
||||||
|
Thank you Yusuke and Cody for your help!
|
||||||
|
|
||||||
## Judges' remarks:
|
## Judges' remarks:
|
||||||
|
|
||||||
One liner programs are short but twisted. This "Hello, World" version
|
One liner programs are short but twisted. This `Hello, world!` version
|
||||||
certainly takes its time saying hello.
|
certainly takes its time saying hello.
|
||||||
|
|
||||||
## Author's remarks:
|
## Author's remarks:
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
main(v,c)char**c;{for(v[c++]=strdup("Hello, world!\n");(!!c)[*c]&&(v--||--c&&execlp(*c,*c,c[!!c]+!!c,!c));**c=!c)write(!!*c,*c,!!**c);}
|
main(v,c)char**c;{for(v[c++]=strdup("Hello, world!\n\n");(!!c)[*c]&&(v--||--c&&execlp(*c,*c,c[!!c]+!!c,!c));**c=!c)write(!!*c,*c,!!**c);}
|
||||||
Reference in new issue
Block a user