Commit 28961c07 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #429 from pbosetti/XCode

Code formatting in sprintf.c
parents 23e88dba 58573c1a
...@@ -483,7 +483,8 @@ mrb_f_sprintf(mrb_state *mrb, mrb_value obj) ...@@ -483,7 +483,8 @@ mrb_f_sprintf(mrb_state *mrb, mrb_value obj)
if (argc <= 0) { if (argc <= 0) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "too few arguments"); mrb_raise(mrb, E_ARGUMENT_ERROR, "too few arguments");
return mrb_nil_value(); return mrb_nil_value();
} else { }
else {
return mrb_str_format(mrb, argc - 1, argv + 1, argv[0]); return mrb_str_format(mrb, argc - 1, argv + 1, argv[0]);
} }
} }
...@@ -598,8 +599,7 @@ retry: ...@@ -598,8 +599,7 @@ retry:
goto retry; goto retry;
case '<': case '<':
case '{': case '{': {
{
const char *start = p; const char *start = p;
char term = (*p == '<') ? '>' : '}'; char term = (*p == '<') ? '>' : '}';
mrb_value symname; mrb_value symname;
...@@ -655,6 +655,7 @@ retry: ...@@ -655,6 +655,7 @@ retry:
case '\n': case '\n':
case '\0': case '\0':
p--; p--;
case '%': case '%':
if (flags != FNONE) { if (flags != FNONE) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid format character - %%"); mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid format character - %%");
...@@ -662,8 +663,7 @@ retry: ...@@ -662,8 +663,7 @@ retry:
PUSH("%", 1); PUSH("%", 1);
break; break;
case 'c': case 'c': {
{
mrb_value val = GETARG(); mrb_value val = GETARG();
mrb_value tmp; mrb_value tmp;
unsigned int c; unsigned int c;
...@@ -705,7 +705,7 @@ retry: ...@@ -705,7 +705,7 @@ retry:
case 's': case 's':
case 'p': case 'p':
format_s: format_s:
{ {
mrb_value arg = GETARG(); mrb_value arg = GETARG();
long len, slen; long len, slen;
...@@ -756,8 +756,7 @@ format_s: ...@@ -756,8 +756,7 @@ format_s:
case 'X': case 'X':
case 'b': case 'b':
case 'B': case 'B':
case 'u': case 'u': {
{
mrb_value val = GETARG(); mrb_value val = GETARG();
char fbuf[32], nbuf[64], *s; char fbuf[32], nbuf[64], *s;
const char *prefix = 0; const char *prefix = 0;
...@@ -793,7 +792,7 @@ format_s: ...@@ -793,7 +792,7 @@ format_s:
} }
} }
bin_retry: bin_retry:
switch (mrb_type(val)) { switch (mrb_type(val)) {
case MRB_TT_FLOAT: case MRB_TT_FLOAT:
if (FIXABLE(mrb_float(val))) { if (FIXABLE(mrb_float(val))) {
...@@ -903,6 +902,7 @@ bin_retry: ...@@ -903,6 +902,7 @@ bin_retry:
pp++; pp++;
} }
} }
if (prefix && !prefix[1]) { /* octal */ if (prefix && !prefix[1]) { /* octal */
if (dots) { if (dots) {
prefix = 0; prefix = 0;
...@@ -918,9 +918,11 @@ bin_retry: ...@@ -918,9 +918,11 @@ bin_retry:
else if (len == 1 && *s == '0') { else if (len == 1 && *s == '0') {
prefix = 0; prefix = 0;
} }
if (prefix) { if (prefix) {
width -= (int)strlen(prefix); width -= (int)strlen(prefix);
} }
if ((flags & (FZERO|FMINUS|FPREC)) == FZERO) { if ((flags & (FZERO|FMINUS|FPREC)) == FZERO) {
prec = width; prec = width;
width = 0; width = 0;
...@@ -932,19 +934,23 @@ bin_retry: ...@@ -932,19 +934,23 @@ bin_retry:
} }
width -= prec; width -= prec;
} }
if (!(flags&FMINUS)) { if (!(flags&FMINUS)) {
CHECK(width); CHECK(width);
while (width-- > 0) { while (width-- > 0) {
buf[blen++] = ' '; buf[blen++] = ' ';
} }
} }
if (sc) PUSH(&sc, 1); if (sc) PUSH(&sc, 1);
if (prefix) { if (prefix) {
int plen = (int)strlen(prefix); int plen = (int)strlen(prefix);
PUSH(prefix, plen); PUSH(prefix, plen);
} }
CHECK(prec - len); CHECK(prec - len);
if (dots) PUSH("..", 2); if (dots) PUSH("..", 2);
if (v < 0 || (base == 2 && org_v < 0)) { if (v < 0 || (base == 2 && org_v < 0)) {
char c = sign_bits(base, p); char c = sign_bits(base, p);
while (len < prec--) { while (len < prec--) {
...@@ -957,6 +963,7 @@ bin_retry: ...@@ -957,6 +963,7 @@ bin_retry:
buf[blen++] = c; buf[blen++] = c;
} }
} }
PUSH(s, len); PUSH(s, len);
CHECK(width); CHECK(width);
while (width-- > 0) { while (width-- > 0) {
...@@ -971,8 +978,7 @@ bin_retry: ...@@ -971,8 +978,7 @@ bin_retry:
case 'e': case 'e':
case 'E': case 'E':
case 'a': case 'a':
case 'A': case 'A': {
{
mrb_value val = GETARG(); mrb_value val = GETARG();
double fval; double fval;
int i, need = 6; int i, need = 6;
......
...@@ -169,10 +169,10 @@ ...@@ -169,10 +169,10 @@
8844358915772EF0007F95A4 /* typeerror.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = typeerror.rb; sourceTree = "<group>"; }; 8844358915772EF0007F95A4 /* typeerror.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = typeerror.rb; sourceTree = "<group>"; };
8844358F1577301B007F95A4 /* mrbtest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = mrbtest; sourceTree = BUILT_PRODUCTS_DIR; }; 8844358F1577301B007F95A4 /* mrbtest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = mrbtest; sourceTree = BUILT_PRODUCTS_DIR; };
8844359A157730DB007F95A4 /* mrbtest.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = mrbtest.c; sourceTree = "<group>"; }; 8844359A157730DB007F95A4 /* mrbtest.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = mrbtest.c; sourceTree = "<group>"; };
88760A9D1575991600113BFB /* mrbc */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = mrbc; path = build/mrbc; sourceTree = "<group>"; }; 88760A9D1575991600113BFB /* mrbc */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = mrbc; path = bin/mrbc; sourceTree = SOURCE_ROOT; };
88760B1715769BE400113BFB /* libmruby_core.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; name = libmruby_core.a; path = build/lib/libmruby_core.a; sourceTree = "<group>"; }; 88760B1715769BE400113BFB /* libmruby_core.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; name = libmruby_core.a; path = lib/libmruby_core.a; sourceTree = SOURCE_ROOT; };
88760B1C15769CEE00113BFB /* mrblib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mrblib.c; sourceTree = "<group>"; }; 88760B1C15769CEE00113BFB /* mrblib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mrblib.c; sourceTree = "<group>"; };
88760B1F15769E2D00113BFB /* libmruby.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; name = libmruby.a; path = build/lib/libmruby.a; sourceTree = "<group>"; }; 88760B1F15769E2D00113BFB /* libmruby.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; name = libmruby.a; path = lib/libmruby.a; sourceTree = SOURCE_ROOT; };
88760B2415769E6100113BFB /* mruby */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = mruby; sourceTree = BUILT_PRODUCTS_DIR; }; 88760B2415769E6100113BFB /* mruby */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = mruby; sourceTree = BUILT_PRODUCTS_DIR; };
88760B3C15769F3000113BFB /* mirb */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = mirb; sourceTree = BUILT_PRODUCTS_DIR; }; 88760B3C15769F3000113BFB /* mirb */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = mirb; sourceTree = BUILT_PRODUCTS_DIR; };
88760B7E1576A33100113BFB /* mruby_fw-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "mruby_fw-Info.plist"; sourceTree = "<group>"; }; 88760B7E1576A33100113BFB /* mruby_fw-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "mruby_fw-Info.plist"; sourceTree = "<group>"; };
...@@ -195,7 +195,6 @@ ...@@ -195,7 +195,6 @@
88BF34E1156C998200F12AC7 /* error.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = error.h; sourceTree = "<group>"; }; 88BF34E1156C998200F12AC7 /* error.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = error.h; sourceTree = "<group>"; };
88BF34E2156C998200F12AC7 /* etc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = etc.c; sourceTree = "<group>"; }; 88BF34E2156C998200F12AC7 /* etc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = etc.c; sourceTree = "<group>"; };
88BF34E5156C998200F12AC7 /* gc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = gc.c; sourceTree = "<group>"; }; 88BF34E5156C998200F12AC7 /* gc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = gc.c; sourceTree = "<group>"; };
88BF34E6156C998200F12AC7 /* gc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gc.h; sourceTree = "<group>"; };
88BF34E7156C998200F12AC7 /* hash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hash.c; sourceTree = "<group>"; }; 88BF34E7156C998200F12AC7 /* hash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hash.c; sourceTree = "<group>"; };
88BF34E8156C998200F12AC7 /* init.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = init.c; sourceTree = "<group>"; }; 88BF34E8156C998200F12AC7 /* init.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = init.c; sourceTree = "<group>"; };
88BF34EA156C998200F12AC7 /* init_ext.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = init_ext.c; sourceTree = "<group>"; }; 88BF34EA156C998200F12AC7 /* init_ext.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = init_ext.c; sourceTree = "<group>"; };
...@@ -491,7 +490,6 @@ ...@@ -491,7 +490,6 @@
88BF34E1156C998200F12AC7 /* error.h */, 88BF34E1156C998200F12AC7 /* error.h */,
88BF34E2156C998200F12AC7 /* etc.c */, 88BF34E2156C998200F12AC7 /* etc.c */,
88BF34E5156C998200F12AC7 /* gc.c */, 88BF34E5156C998200F12AC7 /* gc.c */,
88BF34E6156C998200F12AC7 /* gc.h */,
88BF34E7156C998200F12AC7 /* hash.c */, 88BF34E7156C998200F12AC7 /* hash.c */,
88BF34E8156C998200F12AC7 /* init.c */, 88BF34E8156C998200F12AC7 /* init.c */,
88BF34EA156C998200F12AC7 /* init_ext.c */, 88BF34EA156C998200F12AC7 /* init_ext.c */,
...@@ -835,7 +833,7 @@ ...@@ -835,7 +833,7 @@
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "cd ../test\ncat ./assert.rb ./t/*.rb > mrbtest.rbtmp\n../Xcode/build/mrbc -Bmrbtest_irep -omrbtest.ctmp mrbtest.rbtmp\ncat init_mrbtest.c mrbtest.ctmp > mrbtest.c"; shellScript = "cd ../test\ncat ./assert.rb ./t/*.rb > mrbtest.rbtmp\n../xcode/bin/mrbc -Bmrbtest_irep -omrbtest.ctmp mrbtest.rbtmp\ncat init_mrbtest.c mrbtest.ctmp > mrbtest.c";
}; };
88760AE015759C3600113BFB /* ShellScript */ = { 88760AE015759C3600113BFB /* ShellScript */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
...@@ -848,7 +846,7 @@ ...@@ -848,7 +846,7 @@
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "cd ../mrblib\ncat ./*.rb > mrblib.rbtmp\n../Xcode/build/mrbc -Bmrblib_irep -omrblib.ctmp mrblib.rbtmp\ncat init_mrblib.c mrblib.ctmp > mrblib.c"; shellScript = "cd ../mrblib\ncat ./*.rb > mrblib.rbtmp\n../xcode/bin/mrbc -Bmrblib_irep -omrblib.ctmp mrblib.rbtmp\ncat init_mrblib.c mrblib.ctmp > mrblib.c";
}; };
88760AE915759F5E00113BFB /* ShellScript */ = { 88760AE915759F5E00113BFB /* ShellScript */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
...@@ -874,7 +872,7 @@ ...@@ -874,7 +872,7 @@
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "cd ../mrblib\ncat ./*.rb > mrblib.rbtmp\n../Xcode/build/mrbc -Bmrblib_irep -omrblib.ctmp mrblib.rbtmp\ncat init_mrblib.c mrblib.ctmp > mrblib.c"; shellScript = "cd ../mrblib\ncat ./*.rb > mrblib.rbtmp\n../xcode/bin/mrbc -Bmrblib_irep -omrblib.ctmp mrblib.rbtmp\ncat init_mrblib.c mrblib.ctmp > mrblib.c";
}; };
/* End PBXShellScriptBuildPhase section */ /* End PBXShellScriptBuildPhase section */
......
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0440"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "88760B2315769E6100113BFB"
BuildableName = "mruby"
BlueprintName = "mruby"
ReferencedContainer = "container:mruby.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "88760B3215769F3000113BFB"
BuildableName = "mirb"
BlueprintName = "mirb"
ReferencedContainer = "container:mruby.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8844358E1577301B007F95A4"
BuildableName = "mrbtest"
BlueprintName = "mrbtest"
ReferencedContainer = "container:mruby.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "88760B2315769E6100113BFB"
BuildableName = "mruby"
BlueprintName = "mruby"
ReferencedContainer = "container:mruby.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "88760B3215769F3000113BFB"
BuildableName = "mirb"
BlueprintName = "mirb"
ReferencedContainer = "container:mruby.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "88760B2315769E6100113BFB"
BuildableName = "mruby"
BlueprintName = "mruby"
ReferencedContainer = "container:mruby.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "CLANGDebug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment