public inbox for speakup@linux-speakup.org
 help / color / mirror / Atom feed
From: William Hubbs <w.d.hubbs@gmail.com>
To: "Speakup is a screen review system for Linux." <speakup@braille.uwo.ca>
Subject: Re: [PATCH] Remove trailing newlines from files in /sys/module/speakup/parameters.
Date: Sun, 24 May 2009 16:12:59 -0500	[thread overview]
Message-ID: <20090524211258.GA27067@linux1> (raw)
In-Reply-To: <20090524005718.QKMG17135.fed1rmmtao104.cox.net@fed1rmimpo02.cox.net>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I just applied this patch to speakup; it is now available in the git
tree.

Chris, thanks for the patch.

William

On Sat, May 23, 2009 at 06:49:44PM -0500, Chris Brannon wrote:
> When a user reads a parameter using sysfs, the data that Speakup supplies
> should not end in a newline.  When it does, the corresponding file from
> parameters/ has a blank line at the end.
> 
> Signed-off-by: Christopher Brannon <cmbrannon@cox.net>
> ---
>  src/paramhelpers.c |   24 ++++++++++++++++--------
>  1 files changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/src/paramhelpers.c b/src/paramhelpers.c
> index 7b779a9..7dbd060 100644
> --- a/src/paramhelpers.c
> +++ b/src/paramhelpers.c
> @@ -305,6 +305,12 @@ static int get_characters(char *buffer, struct kernel_param *kp)
>  		cp = (characters[i]) ? characters[i] : "NULL";
>  		len += sprintf(buffer + len, "%d\t%s\n", i, cp);
>  	}
> +
> +	/* Loop leaves a newline at the end of the buffer, but buffer
> +	 * shouldn't end with a newline.  Snip it.
> +	*/
> +	buffer[--len] = '\0';
> +
>  	return len;
>  }
>  
> @@ -421,6 +427,9 @@ static int get_chartab(char *buffer, struct kernel_param *kp)
>  			cp = "B_SYM";
>  		len += sprintf(buffer + len, "%d\t%s\n", i, cp);
>  	}
> +
> +	/* Buffer should not end in a newline.  Snip it. */
> +	buffer[--len] = '\0';
>  	return len;
>  }
>  
> @@ -509,7 +518,7 @@ static int get_keymap(char *buffer, struct kernel_param *kp)
>  			*cp++ = (i < nstates) ? SPACE : '\n';
>  		}
>  	}
> -	cp += sprintf(cp, "0, %d\n", KEY_MAP_VER);
> +	cp += sprintf(cp, "0, %d", KEY_MAP_VER);
>  	return (int)(cp-buffer);
>  }
>  
> @@ -632,9 +641,9 @@ static int get_version(char *buffer, struct kernel_param *kp)
>  	char *cp;
>  
>  	cp = buffer;
> -	cp += sprintf(cp, "Speakup version %s\n", SPEAKUP_VERSION);
> +	cp += sprintf(cp, "Speakup version %s", SPEAKUP_VERSION);
>  	if (synth != NULL)
> -		cp += sprintf(cp, "%s synthesizer driver version %s\n",
> +		cp += sprintf(cp, "\n%s synthesizer driver version %s",
>  		synth->name, synth->version);
>  	return cp - buffer;
>  }
> @@ -807,9 +816,9 @@ static int get_vars(char *buffer, struct kernel_param *kp)
>  	case VAR_NUM:
>  	case VAR_TIME:
>  		if (var)
> -			rv = sprintf(buffer, "%i\n", var->u.n.value);
> +			rv = sprintf(buffer, "%i", var->u.n.value);
>  		else
> -			rv = sprintf(buffer, "0\n");
> +			rv = sprintf(buffer, "0");
>  		break;
>  	case VAR_STRING:
>  		if (var) {
> @@ -822,15 +831,14 @@ static int get_vars(char *buffer, struct kernel_param *kp)
>  					cp1 += sprintf(cp1, "\\""x%02x", ch);
>  			}
>  			*cp1++ = '"';
> -			*cp1++ = '\n';
>  			*cp1 = '\0';
>  			rv = cp1-buffer;
>  		} else {
> -			rv = sprintf(buffer, "\"\"\n");
> +			rv = sprintf(buffer, "\"\"");
>  		}
>  		break;
>  	default:
> -		rv = sprintf(buffer, "Bad parameter  %s, type %i\n",
> +		rv = sprintf(buffer, "Bad parameter  %s, type %i",
>  			param->name, param->var_type);
>  		break;
>  	}
> -- 
> 1.6.3.1
> 
> _______________________________________________
> Speakup mailing list
> Speakup@braille.uwo.ca
> http://speech.braille.uwo.ca/mailman/listinfo/speakup
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)

iEYEARECAAYFAkoZuFoACgkQblQW9DDEZTh+AQCfXyHnrClBe5VDKPAHQaXWyXCy
H1YAoIxd5WYo4I+b88gyTLep/0VMav8o
=PrZQ
-----END PGP SIGNATURE-----

      reply	other threads:[~ UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
 Christopher Brannon
 ` William Hubbs [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090524211258.GA27067@linux1 \
    --to=w.d.hubbs@gmail.com \
    --cc=speakup@braille.uwo.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).