[syslinux] rosh patch
Gene Cumm
gene.cumm at gmail.com
Fri Mar 6 15:53:02 PST 2009
On Thu, Mar 5, 2009 at 10:13 PM, Keith Schincke
<keith.schincke at gmail.com> wrote:
> Hey Guys,
>
> Below is a patch for the com32/rosh/rosh.c from tonights syslinx git.
> The patch does the following:
> 1) changes the rosh_issp to use an if instead of a case for this simple
> test.
> 2) changes the rosh_dir_arg function to move the readdir() to inside the
> while test.
>
> This will let me go through my APUE book.
>
> Let me know if you have any questions.
>
> Keith
>
> --- rosh.orig 2009-03-05 20:32:59.000000000 -0500
> +++ rosh.c 2009-03-05 22:09:55.000000000 -0500
> @@ -60,11 +60,11 @@
> */
> int rosh_issp(char inc)
> {
> - int rv;
> - switch (inc){
> - case ' ': case '\t':
> - rv = 1; break;
> - default: rv = 0;
> + int rv = 0 ;
> +
> + if ( ( inc == ' ') || ( inc == '\t') )
> + {
> + rv = 1 ;
> }
> return rv;
> } /* ros_issp */
Presetting rv (and other simple return values) is something I think
I'm going to have to do on quite a few functions. Thanks for noting
it.
As far as switch versus if, I'm definitely uncertain which is better.
I should probably make another function that checks if it's a
whitespace character as that's a little more relevant to what I'm
trying to do.
With regards to the braces, they're deemed unneeded as it's only one line.
> @@ -384,8 +384,7 @@
> if (S_ISDIR(fdstat.st_mode)) {
> ROSH_DEBUG("PATH '%s' is a directory\n", ifilstr);
> d = fdopendir(fd);
> - de = readdir(d);
> - while (de != NULL) {
> + while ( de = readdir(d) ) {
> #ifdef DO_DEBUG
> filestr2[0] = 0;
> file2pos = strlen(filestr);
> @@ -401,7 +400,6 @@
> #ifdef DO_DEBUG
> // inchar = fgetc(stdin);
> #endif /* DO_DEBUG */
> - de = readdir(d);
> }
> closedir(d);
> } else if (S_ISREG(fdstat.st_mode)) {
OK.
--
-Gene
More information about the Syslinux
mailing list