1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-11-22 02:20:16 +02:00

change use of curly braces with "if-else" to kernel style

This commit is contained in:
Werner Almesberger 2012-05-25 13:33:54 -03:00
parent 6623ae198f
commit 424b74e482
9 changed files with 45 additions and 46 deletions

7
dump.c
View File

@ -1,8 +1,8 @@
/*
* dump.c - Dump objects in the native FPD format
*
* Written 2009-2011 by Werner Almesberger
* Copyright 2009-2011 by Werner Almesberger
* Written 2009-2012 by Werner Almesberger
* Copyright 2009-2012 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -488,9 +488,8 @@ char *print_vec(const struct vec *vec)
y = unparse(vec->y);
if (vec->name)
s = stralloc_printf("vec %s(%s, %s)", base, x, y);
else {
else
s = stralloc_printf("vec %s(%s, %s)", base, x, y);
}
free(x);
free(y);
return s;

12
expr.c
View File

@ -1,8 +1,8 @@
/*
* expr.c - Expressions and values
*
* Written 2009, 2010 by Werner Almesberger
* Copyright 2009, 2010 by Werner Almesberger
* Written 2009, 2010, 2012 by Werner Almesberger
* Copyright 2009, 2010, 2012 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -443,9 +443,9 @@ char *expand(const char *name, const struct frame *frame)
while (is_id_char(*s, s == s0))
s++;
if (s == s0) {
if (*s)
if (*s) {
goto invalid;
else {
} else {
fail("incomplete variable name");
goto fail;
}
@ -472,9 +472,9 @@ char *expand(const char *name, const struct frame *frame)
var_unique = unique(var);
free(var);
value_string = eval_string_var(frame, var_unique);
if (value_string)
if (value_string) {
value_len = strlen(value_string);
else {
} else {
value = eval_var(frame, var_unique);
if (is_undef(value)) {
fail("undefined variable \"%s\"", var_unique);

12
file.c
View File

@ -1,8 +1,8 @@
/*
* file.c - File handling
*
* Written 2009-2011 by Werner Almesberger
* Copyright 2009-2011 by Werner Almesberger
* Written 2009-2012 by Werner Almesberger
* Copyright 2009-2012 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -91,9 +91,9 @@ void save_with_backup(const char *name, int (*fn)(FILE *file, const char *one),
/* save to temporary file */
slash = strrchr(s, '/');
if (!slash)
if (!slash) {
tmp = stralloc_printf("~%s", s);
else {
} else {
*slash = 0;
tmp = stralloc_printf("%s/~%s", s, slash+1);
*slash = '/';
@ -148,9 +148,9 @@ void save_with_backup(const char *name, int (*fn)(FILE *file, const char *one),
void save_fpd(void)
{
if (save_file_name)
if (save_file_name) {
save_with_backup(save_file_name, dump, NULL);
else {
} else {
if (!dump(stdout, NULL))
perror("stdout");
}

8
fpd.y
View File

@ -2,8 +2,8 @@
/*
* fpd.y - FootPrint Definition language
*
* Written 2009-2011 by Werner Almesberger
* Copyright 2009-2011 by Werner Almesberger
* Written 2009-2012 by Werner Almesberger
* Copyright 2009-2012 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -252,9 +252,9 @@ static int dbg_delete(const char *frame_name, const char *name)
struct obj *obj;
struct frame *frame;
if (!frame_name)
if (!frame_name) {
frame = curr_frame;
else {
} else {
frame = find_frame(frame_name);
if (!frame) {
yyerrorf("unknown frame \"%s\"", frame_name);

View File

@ -1,8 +1,8 @@
/*
* gui_frame.c - GUI, frame window
*
* Written 2009, 2010 by Werner Almesberger
* Copyright 2009, 2010 by Werner Almesberger
* Written 2009, 2010, 2012 by Werner Almesberger
* Copyright 2009, 2010, 2012 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -616,9 +616,9 @@ static void show_value(const struct expr *expr, const struct frame *frame)
status_set_type_x(NULL, "value =");
value_string = eval_str(expr, frame);
if (value_string)
if (value_string) {
status_set_x(NULL, "\"%s\"", value_string);
else {
} else {
value = eval_num(expr, frame);
if (is_undef(value))
status_set_x(NULL, "undefined");
@ -1701,9 +1701,9 @@ static gboolean frame_release_event(GtkWidget *widget, GdkEventButton *event,
case 1:
if (is_dragging(frame))
return FALSE;
if (active_frame != frame)
if (active_frame != frame) {
select_frame(frame);
else {
} else {
if (active_frame->name) {
edit_nothing();
edit_frame(frame);

View File

@ -1,8 +1,8 @@
/*
* gui_inst.c - GUI, instance functions
*
* Written 2009-2011 by Werner Almesberger
* Copyright 2009-2011 by Werner Almesberger
* Written 2009-2012 by Werner Almesberger
* Copyright 2009-2012 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -79,9 +79,9 @@ static void draw_poly(GdkGC *gc, int fill,
gp[i].x = points[i].x;
gp[i].y = points[i].y;
}
if (fill)
if (fill) {
gdk_draw_polygon(DA, gc, fill, gp, n_points);
else {
} else {
gdk_draw_line(DA, gc, gp[0].x, gp[0].y, gp[1].x, gp[1].y);
gdk_draw_line(DA, gc, gp[1].x, gp[1].y, gp[2].x, gp[2].y);
}
@ -359,10 +359,10 @@ static void draw_rounded_rect(GdkGC *gc, struct coord a, struct coord b,
if (h > w) {
r = w/2;
draw_arc(DA, gc, fill, min.x+r, max.y-r, r, 180, 0);
if (fill)
if (fill) {
gdk_draw_rectangle(DA, gc, fill,
min.x, min.y+r, w, h-2*r);
else {
} else {
gdk_draw_line(DA, gc, min.x, min.y+r, min.x, max.y-r);
gdk_draw_line(DA, gc, max.x, min.y+r, max.x, max.y-r);
}
@ -370,10 +370,10 @@ static void draw_rounded_rect(GdkGC *gc, struct coord a, struct coord b,
} else {
r = h/2;
draw_arc(DA, gc, fill, min.x+r, min.y+r, r, 90, 270);
if (fill)
if (fill) {
gdk_draw_rectangle(DA, gc, fill,
min.x+r, min.y, w-2*r, h);
else {
} else {
gdk_draw_line(DA, gc, min.x+r, min.y, max.x-r, min.y);
gdk_draw_line(DA, gc, min.x+r, max.y, max.x-r, max.y);
}

View File

@ -1,8 +1,8 @@
/*
* gui_tool.c - GUI, tool bar
*
* Written 2009-2011 by Werner Almesberger
* Copyright 2009-2011 by Werner Almesberger
* Written 2009-2012 by Werner Almesberger
* Copyright 2009-2012 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -556,9 +556,9 @@ struct pix_buf *draw_move_arc(struct inst *inst, struct coord pos, int i)
if (a2 < a1)
a2 += 360.0;
if (i != 2)
if (i != 2) {
r_save = r;
else {
} else {
r_save = hypot(to.x-c.x, to.y-c.y);
if (r > r_save)
r_save = r;
@ -1025,9 +1025,9 @@ int tool_end_drag(struct coord to)
tool_cancel_drag();
if (state.new && ops->end_new_raw)
return ops->end_new_raw(state.new, to);
if (state.new && ops->find_point)
if (state.new && ops->find_point) {
end = ops->find_point(to);
else {
} else {
if (state.inst && state.inst->ops->find_point)
end = state.inst->ops->find_point(state.inst, to);
else

8
inst.c
View File

@ -509,9 +509,9 @@ static void rect_status(struct coord a, struct coord b, unit_type width,
status_set_xy(d);
tip = "Angle of diagonal";
if (!d.x && !d.y)
if (!d.x && !d.y) {
status_set_angle(tip, "a = 0 deg");
else {
} else {
status_set_angle(tip, "a = %3.1f deg", theta(a, b));
}
if (d.x < 0)
@ -716,9 +716,9 @@ static void do_move_to_vec(struct inst *inst, struct inst *to, int i)
walk = &frame->vecs;
while (*walk != to_vec) {
v = *walk;
if (!v->mark)
if (!v->mark) {
walk = &v->next;
else {
} else {
*walk = v->next;
v->next = *anchor;
*anchor = v;

View File

@ -1135,9 +1135,9 @@ static void ps_package_fullpage(FILE *file, const struct pkg *pkg, int page)
bbox = inst_get_bbox();
cx = (bbox.min.x+bbox.max.x)/2;
cy = (bbox.min.y+bbox.max.y)/2;
if (active_params.zoom)
if (active_params.zoom) {
f = active_params.zoom;
else {
} else {
fx = 2.0*PAGE_HALF_WIDTH/(bbox.max.x-bbox.min.x);
fy = 2.0*PAGE_HALF_HEIGHT/(bbox.max.y-bbox.min.y);
f = fx < fy ? fx : fy;