Mercurial Hosting > luan
comparison src/luan/lib/StringLib.java @ 130:0594c132888b
cleanup
git-svn-id: https://luan-java.googlecode.com/svn/trunk@131 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Tue, 10 Jun 2014 02:43:40 +0000 |
parents | f537ff5e511d |
children | 3119326260ea |
comparison
equal
deleted
inserted
replaced
129:486a0641bca4 | 130:0594c132888b |
---|---|
220 String match = m.groupCount()==0 ? m.group() : m.group(1); | 220 String match = m.groupCount()==0 ? m.group() : m.group(1); |
221 Object val = t.get(match); | 221 Object val = t.get(match); |
222 if( Luan.toBoolean(val) ) { | 222 if( Luan.toBoolean(val) ) { |
223 String replacement = Luan.asString(val); | 223 String replacement = Luan.asString(val); |
224 if( replacement==null ) | 224 if( replacement==null ) |
225 throw luan.JAVA.exception( "invalid replacement value (a "+Luan.type(val)+")" ); | 225 throw luan.exception( "invalid replacement value (a "+Luan.type(val)+")" ); |
226 m.appendReplacement(sb,replacement); | 226 m.appendReplacement(sb,replacement); |
227 } | 227 } |
228 i++; | 228 i++; |
229 } | 229 } |
230 m.appendTail(sb); | 230 m.appendTail(sb); |
243 args = new Object[count]; | 243 args = new Object[count]; |
244 for( int j=0; j<count; j++ ) { | 244 for( int j=0; j<count; j++ ) { |
245 args[j] = m.group(j); | 245 args[j] = m.group(j); |
246 } | 246 } |
247 } | 247 } |
248 Object val = Luan.first( luan.JAVA.call(fn,"repl-arg",args) ); | 248 Object val = Luan.first( luan.call(fn,"repl-arg",args) ); |
249 if( Luan.toBoolean(val) ) { | 249 if( Luan.toBoolean(val) ) { |
250 String replacement = Luan.asString(val); | 250 String replacement = Luan.asString(val); |
251 if( replacement==null ) | 251 if( replacement==null ) |
252 throw luan.JAVA.exception( "invalid replacement value (a "+Luan.type(val)+")" ); | 252 throw luan.exception( "invalid replacement value (a "+Luan.type(val)+")" ); |
253 m.appendReplacement(sb,replacement); | 253 m.appendReplacement(sb,replacement); |
254 } | 254 } |
255 i++; | 255 i++; |
256 } | 256 } |
257 m.appendTail(sb); | 257 m.appendTail(sb); |
258 return new Object[]{ sb.toString(), i }; | 258 return new Object[]{ sb.toString(), i }; |
259 } | 259 } |
260 throw luan.JAVA.exception( "bad argument #3 to 'gsub' (string/function/table expected)" ); | 260 throw luan.exception( "bad argument #3 to 'gsub' (string/function/table expected)" ); |
261 } | 261 } |
262 | 262 |
263 // note - String.format() is too stupid to convert between ints and floats. | 263 // note - String.format() is too stupid to convert between ints and floats. |
264 public static String format(String format,Object... args) { | 264 public static String format(String format,Object... args) { |
265 return String.format(format,args); | 265 return String.format(format,args); |