[Vm-dev] [commit][3255] squeak -help says that the default encoding for external text is UTF-8, make it so.

Wolfgang Eder edw at generalmagic.at
Fri Feb 13 13:13:19 UTC 2015


strcmp answers zero if the strings are the same.
zero, interpreted as a boolean, is false.
so, !strcmp() means that the strings are equal.
kind regards wolfgang

> Am 13.02.2015 um 14:02 schrieb Henrik Johansen <henrik.s.johansen at veloxit.no>:
> 
> 
> 
>> On 13 Feb 2015, at 4:00 , commits at squeakvm.org wrote:
>> 
>> 
>> Revision: 3255
>> Author:   lewis
>> Date:     2015-02-12 19:00:34 -0800 (Thu, 12 Feb 2015)
>> Log Message:
>> -----------
>> squeak -help says that the default encoding for external text is UTF-8, make it so.
>> 
>> Modified Paths:
>> --------------
>>   trunk/platforms/unix/vm/sqUnixMain.c
>> 
>> Modified: trunk/platforms/unix/vm/sqUnixMain.c
>> ===================================================================
>> --- trunk/platforms/unix/vm/sqUnixMain.c	2015-02-12 19:20:06 UTC (rev 3254)
>> +++ trunk/platforms/unix/vm/sqUnixMain.c	2015-02-13 03:00:34 UTC (rev 3255)
>> @@ -99,7 +99,7 @@
>>       int    uxDropFileCount=	0;	/* number of dropped items	*/
>>       char **uxDropFileNames=	0;	/* dropped filenames		*/
>> 
>> -       int    textEncodingUTF8= 0;	/* 1 if copy from external selection uses UTF8 */
>> +       int    textEncodingUTF8= 1;	/* 1 if copy from external selection uses UTF8 */
>> 
>> #if defined(IMAGE_DUMP)
>> static int    dumpImageFile=	0;	/* 1 after SIGHUP received */
>> @@ -1082,10 +1082,11 @@
>> 	  len= strlen(buf);
>> 	  for (i= 0;  i < len;  ++i)
>> 	    buf[i]= toupper(buf[i]);
>> -	  if ((!strcmp(buf, "UTF8")) || (!strcmp(buf, "UTF-8")))
>> -	    textEncodingUTF8= 1;
>> -	  else
>> -	    setEncoding(&uxTextEncoding, buf);
>> +	  if (strcmp(buf, "UTF8") && strcmp(buf, "UTF-8"))
>> +	    {
>> +	      textEncodingUTF8= 0;
>> +	      setEncoding(&uxTextEncoding, buf);
>> +	    }
>> 	  free(buf);
>> 	  return 2;
>> 	}
>> 
> 
> Wait, wat?
> They way I read that, it says, "If buf is both "UTF8" and "UTF-8", set the text encoding to not be utf8"?
> I don't get how the initial version could work either (the if/else blocks look reversed, for my interpretation "if buf is neither UTF8 nor UTF-8"... ), but does anyone fluent in C have time to explain to me how the new version works / how I'm reading wrong?
> 
> Cheers,
> Henry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4139 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20150213/b4f9579e/smime.bin


More information about the Vm-dev mailing list