[irstlm] 91/126: bug fixed related to reading integer values for parameters

Giulio Paci giuliopaci-guest at moszumanska.debian.org
Tue May 17 07:46:48 UTC 2016


This is an automated email from the git hooks/post-receive script.

giuliopaci-guest pushed a commit to annotated tag adaptiveLM.v0.1
in repository irstlm.

commit caff2e3764eb15bdbd2b1fd433aeaf2846c2c5a5
Author: Nicola Bertoldi <bertoldi at fbk.eu>
Date:   Fri Sep 18 15:42:31 2015 +0200

    bug fixed related to reading integer values for parameters
---
 src/cmd.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/cmd.c b/src/cmd.c
index e95d964..1a0dfee 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -737,7 +737,10 @@ SetParam(Cmd_T	*cmd,
 			SetFlag(cmd, s);
 			break;
 		case CMDINTTYPE:
-			if(sscanf(s, "%i", (int*)cmd->Val)!=1) {
+			/*They are the same when used for output, e.g. with printf, but different when used as input specifier e.g. with scanf, where %d scans an integer as a signed decimal number, but %i defaults to decimal but also allows hexadecimal (if preceded by "0x") and octal if preceded by "0".
+			 So "033" would be 27 with %i but 33 with %d.
+			 */
+			if(sscanf(s, "%d", (int*)cmd->Val)!=1) {
 				fprintf(stderr,
 								"Integer value required for parameter \"%s\"\n",
 								cmd->Name);
@@ -872,8 +875,11 @@ SetSubrange(Cmd_T	*cmd,
 						char	*s)
 {
 	int	n;
-	
-	if(sscanf(s, "%i", &n)!=1) {
+
+	/*They are the same when used for output, e.g. with printf, but different when used as input specifier e.g. with scanf, where %d scans an integer as a signed decimal number, but %i defaults to decimal but also allows hexadecimal (if preceded by "0x") and octal if preceded by "0".
+	 So "033" would be 27 with %i but 33 with %d.
+	 */
+	if(sscanf(s, "%d", &n)!=1) {
 		fprintf(stderr,
 						"Integer value required for parameter \"%s\"\n",
 						cmd->Name);
@@ -892,7 +898,10 @@ SetGte(Cmd_T	*cmd,
 {
 	int	n;
 	
-	if(sscanf(s, "%i", &n)!=1) {
+	/*They are the same when used for output, e.g. with printf, but different when used as input specifier e.g. with scanf, where %d scans an integer as a signed decimal number, but %i defaults to decimal but also allows hexadecimal (if preceded by "0x") and octal if preceded by "0".
+		So "033" would be 27 with %i but 33 with %d.
+		*/
+	if(sscanf(s, "%d", &n)!=1) {
 		fprintf(stderr,
 						"Integer value required for parameter \"%s\"\n",
 						cmd->Name);
@@ -928,7 +937,10 @@ SetLte(Cmd_T	*cmd,
 {
 	int	n;
 	
-	if(sscanf(s, "%i", &n)!=1) {
+	/*They are the same when used for output, e.g. with printf, but different when used as input specifier e.g. with scanf, where %d scans an integer as a signed decimal number, but %i defaults to decimal but also allows hexadecimal (if preceded by "0x") and octal if preceded by "0".
+	 So "033" would be 27 with %i but 33 with %d.
+	 */
+	if(sscanf(s, "%d", &n)!=1) {
 		fprintf(stderr,
 						"Integer value required for parameter \"%s\"\n",
 						cmd->Name);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/irstlm.git



More information about the debian-science-commits mailing list