From 056c78020be0ae20bbb368cd141c1403223ba8b7 Mon Sep 17 00:00:00 2001 From: flaviut Date: Mon, 26 May 2014 10:39:37 -0400 Subject: [PATCH 1/2] Fix #1226 --- compiler/ccgtypes.nim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 7c11d3e9af..79bf11bd2f 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -13,8 +13,7 @@ proc mangleField(name: string): string = result = mangle(name) - if name[0] in 'a'..'z': - result[0] = name[0].toUpper + result[0] = result[0].toUpper proc isKeyword(w: PIdent): bool = # nimrod and C++ share some keywords From 85e6e2a240bf7c9766dce86ec44368997adb58f1 Mon Sep 17 00:00:00 2001 From: flaviut Date: Mon, 26 May 2014 10:44:14 -0400 Subject: [PATCH 2/2] Document mangling --- compiler/ccgtypes.nim | 3 ++- compiler/ccgutils.nim | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 79bf11bd2f..7a490082f0 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -13,7 +13,8 @@ proc mangleField(name: string): string = result = mangle(name) - result[0] = result[0].toUpper + result[0] = result[0].toUpper # Mangling makes everything lowercase, + # but some identifiers are C keywords proc isKeyword(w: PIdent): bool = # nimrod and C++ share some keywords diff --git a/compiler/ccgutils.nim b/compiler/ccgutils.nim index 9beb08a219..04983d6a4f 100644 --- a/compiler/ccgutils.nim +++ b/compiler/ccgutils.nim @@ -162,6 +162,9 @@ proc makeSingleLineCString*(s: string): string = result.add('\"') proc mangle*(name: string): string = + ## Lowercases the given name and manges any non-alphanumeric characters + ## so they are represented as `HEX____`. If the name starts with a number, + ## `N` is prepended result = "" case name[0] of Letters: