Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

suckless unix tools

Name: Anonymous 2015-04-02 21:41

Name: Anonymous 2015-04-29 17:03

ACU is indeed superior: http://sprunge.us/BcDT

That's a handrolled dirname(3) implementation that nobody can read. I guess using the standard dirname is overkill here.

I particularly enjoy the step_6 label.

Name: Anonymous 2015-04-29 17:15

>>146
step_6:
//i inits with length of argument 1(directory) = last letter of dirname
//if (current letter of dirname is not NULL(superfluous) and is '/'(slash separator ) decrement i at end of loop
for(i=strlen(argv[1])-1;argv[1][i]&&argv[1][i]=='/';i--)
//set current letter to NULL(0) truncating the string
argv[1][i]=0;
if(argv[1][0])//if first letter isn't NULL
printf("%s\n",argv[1]);//print dirname
else
single_slash: printf("/\n");

Name: Anonymous 2015-04-29 18:39

>>147
Faggot
step_6:
for(i=strlen(argv[1])-1;argv[1][i]&&argv[1][i]=='/';i--)
argv[1][i]=0;
if(argv[1][0])
printf("%s\n",argv[1]);
else
single_slash: printf("/\n");
} else
single_dot:
printf(".\n");

Name: Anonymous 2015-04-29 18:49

puts(dirname(argv[1]));

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List