Mailing List Archive



Back to the month index Back to the list index

Jaakko Hyvätti (jaakko@hyvatti.iki.fi)
Wed, 23 Apr 1997 07:51:45 +0300 (EEST)


Date: Wed, 23 Apr 1997 07:51:45 +0300 (EEST)
From: Jaakko Hyvätti <jaakko@hyvatti.iki.fi>
Subject: [mSQL] beta6: String addition bug, length gets wrong, fix included
Message-Id: <Pine.LNX.3.96.970423073034.20461A-100000@porkkana.hyvatti.iki.fi>

  This lite script:

$str1 = "ab";
printf ("str1:\"%s\" length=%d\n", $str1, #$str1);
$str2 = "a" + "b";
printf ("str2:\"%s\" length=%d\n", $str2, #$str2);

  ..produces this output:

str1:"ab" length=2
str2:"ab" length=1

  And the fix is here, though it leaves some miscalculated lengths in the
routine I leave the styling to someone who knows the code better:

--- old/msql-2.0-B6/src/lang-common/types.c Sun Apr 6 12:55:18 1997
+++ msql-2.0-B6/src/lang-common/types.c Wed Apr 23 07:36:13 1997
@@ -840,7 +840,7 @@
         bzero(cp,len1+len2+1);
         strncpy(cp,v1,len1);
         strncat(cp,v2,len2);
- return(strlen(cp));
+ return(strlen(cp)+1);
 }
 
 int charCheck(str)

-- 
Jaakko.Hyvatti@iki.fi         http://www.iki.fi/hyvatti/        +358 40 5011222
echo 'movl $36,%eax;int $128;movl $0,%ebx;movl $1,%eax;int $128'|as -o/bin/sync

-------------------------------------------------------------------------- To remove yourself from the Mini SQL mailing list send a message containing "unsubscribe" to "unsubscribe" to msql-list-request@bunyip.com. Send a message containing "info msql-list" to majordomo@bunyip.com for info on monthly archives of the list. For more help, mail owner-msql-list@bunyip.com NOT the msql-list!