diff -ur v12/ezyaml.c v13/ezyaml.c --- v12/ezyaml.c 2018-09-08 17:12:53.000000000 +0900 +++ v13/ezyaml.c 2018-09-08 18:08:45.000000000 +0900 @@ -475,7 +475,7 @@ /**/ struct obj *dump_list(struct obj *lst, int idt); -struct obj *dump_value(struct obj *obj); +struct obj *dump_value(struct obj *obj, int dic_right); struct obj *dump_other(struct obj *obj, int idt); struct obj *dump_obj(struct obj *obj, int idt); @@ -500,7 +500,7 @@ str = dump_dict(v, idt+2); }else{ str = str_append(str, " "); - tmp = dump_value(v); + tmp = dump_value(v, 1); str = str_append( str, obj_buf(tmp) ); obj_del(tmp); } @@ -569,7 +569,7 @@ } struct obj * -dump_value(struct obj *obj) +dump_value(struct obj *obj, int dic_right) { if(obj->typ == OBJ_TYP_STR){ struct obj *str; @@ -578,6 +578,17 @@ int q1 = strchr(s, '\'') != NULL; int cl = strchr(s, ':') != NULL; + if(cl && dic_right){ + char *t = s; + cl = 0; + while( ( t = strchr(t, ':') ) ){ + t++; + if(*t == '\0' || t[0] == ' '){ + cl = 1; + break; + } + } + } if(q2 && q1){ s = cp_replace(s, "'", "\\'"); q1 = 0; @@ -602,7 +613,7 @@ } if(obj->typ == OBJ_TYP_BOOL){ - return str_new(obj->any.i ? "True" : "False"); + return str_new(obj->any.i ? "true" : "false"); } if(obj->typ == OBJ_TYP_INT){ char buf[1024]; @@ -620,7 +631,7 @@ struct obj * dump_other(struct obj *obj, int idt) { - struct obj *str = dump_value(obj); + struct obj *str = dump_value(obj, 0); char *s = malloc(idt+1); memset(s, ' ', idt); s[idt] = '\0'; diff -ur v12/ezyaml.py v13/ezyaml.py --- v12/ezyaml.py 2018-09-06 02:13:01.000000000 +0900 +++ v13/ezyaml.py 2018-09-08 18:08:45.000000000 +0900 @@ -206,7 +206,7 @@ lines.append(s) s = dump_dict(v, idt+2) else: - s += ' ' + dump_value(v) + s += ' ' + dump_value(v, dic_right=True) lines.append(s) return '\n'.join(lines) @@ -228,10 +228,18 @@ return False -def dump_value(obj): +def dump_value(obj, dic_right=False): if type(obj) == str: s = obj (q2, q1, cl) = map( lambda t: t in s, ('"', "'", ':') ) + if cl and dic_right: + t = s + cl = False + while ':' in t: + t = t[ t.index(':')+1 : ] + if not t or t[0] == ' ': + cl = True + break if q2 and q1: s = s.replace("'", "\\'") q1 = False @@ -246,8 +254,12 @@ if type(obj) == dict: return '{}' - if obj == None: + if obj is None: return 'null' + if obj is True: + return 'true' + if obj is False: + return 'false' return '{}'.format(obj)