make code ANSI-C compliant

This commit is contained in:
frese 2003-04-17 14:53:27 +00:00
parent e7108c64ca
commit f12cd06a4e
15 changed files with 60 additions and 53 deletions

View File

@ -1,11 +1,11 @@
#include "scheme48.h"
extern void scx_init_xlib();
//extern void scx_init_xpm();
/*extern void scx_init_xpm();*/
int main(int argc, char **argv) {
s48_add_external_init(scx_init_xlib);
//s48_add_external_init(scx_init_xpm);
/*s48_add_external_init(scx_init_xpm);*/
s48_main(8000000, 64000,
SCSHIMAGE,

View File

@ -389,7 +389,7 @@ s48_value scx_Get_Wm_Normal_Hints(s48_value dpy, s48_value win) {
scx_extract_window(win),
&SH, &supplied_by_user))
return S48_FALSE;
// ignoring supplied_by_user ... ?!
/* ignoring supplied_by_user ... ?! */
return scx_enter_size_hint_alist(&SH);
}

View File

@ -67,7 +67,8 @@ s48_value scx_enter_display(Display* dpy) {
d = s48_make_record(scx_display);
S48_GC_PROTECT_2(d, l);
// have to do this first, because screens want to reference their display
/* have to do this first, because screens want to reference their
display */
scx_struct_cache_set(dpy, &scx_display_list, d);
S48_RECORD_SET(d, 0, s48_enter_integer((long)dpy));
@ -89,7 +90,7 @@ s48_value scx_enter_display(Display* dpy) {
S48_RECORD_SET(d, 13, l);
S48_RECORD_SET(d, 14, S48_FALSE);
XSetAfterFunction(dpy, &scx_after_function_wrapper);
S48_RECORD_SET(d, 15, S48_FALSE); // wakeup placeholder
S48_RECORD_SET(d, 15, S48_FALSE);
s48_call_scheme(S48_SHARED_BINDING_REF(s48_get_imported_binding(
"scx-initialize-display")), 1, d);
S48_GC_UNPROTECT();

View File

@ -7,7 +7,7 @@ s48_value scx_enter_error_code(int code) {
if (code < S48_VECTOR_LENGTH(v))
return S48_VECTOR_REF(v, code);
else
return s48_enter_integer(code); // Extension Errors
return s48_enter_integer(code); /* Extension Errors */
}
s48_value scx_extract_error_code(s48_value code) {
@ -94,16 +94,17 @@ s48_value scx_Get_Error_Database_Text(s48_value display, s48_value name,
s48_value internal_x_fatal_error_handler_binding = S48_FALSE;
static int fatal_error_handler_wrapper(Display* d) {
// call the scheme-func internal-x-fatal-error-handler, which does the rest.
/* call the scheme-func internal-x-fatal-error-handler, which does
the rest. */
if ((internal_x_fatal_error_handler_binding != S48_FALSE) &&
(S48_SHARED_BINDING_REF(internal_x_fatal_error_handler_binding)
!= S48_FALSE))
s48_call_scheme(S48_SHARED_BINDING_REF(
internal_x_fatal_error_handler_binding),
1, scx_enter_display(d));
// In case the scheme error handler does not exit (or none exists):
/* In case the scheme error handler does not exit (or none exists): */
_XDefaultIOError (d);
// And if even the default handler does not exit:
/* And if even the default handler does not exit: */
exit(1);
/*NOTREACHED*/
return 0;

View File

@ -382,10 +382,10 @@ s48_value scx_enter_event(XEvent* e) {
case MappingNotify :
return scx_enter_mapping_event((XMappingEvent*)e);
default: return S48_FALSE;
} // switch end
} /* switch end */
}
// *** extraction ****************************************************
/*** extraction ****************************************************/
#define EEXTRACT(i, name, f) xe->name = f(S48_RECORD_REF(e, i))
#define EEXTRACT_START(stype) \
@ -674,10 +674,10 @@ void scx_extract_colormap_event(s48_value e, XColormapEvent* xe) {
}
void scx_extract_client_message_event(s48_value e, XClientMessageEvent* xe) {
EEXTRACT_START("scx-client-message-event");
EEXTRACT(4, window, scx_extract_window);
int nelements, i;
char* data;
EEXTRACT_START("scx-client-message-event");
EEXTRACT(4, window, scx_extract_window);
scx_extract_property(S48_RECORD_REF(e, 5), &xe->message_type, &xe->format,
&data, &nelements);
for (i = 0; i < 20; i++)
@ -701,7 +701,7 @@ void scx_extract_mapping_event(s48_value e, XMappingEvent* xe) {
void scx_extract_keymap_event(s48_value e, XKeymapEvent* xe) {
s48_value temp; int i;
EEXTRACT_START("scx-keymap-event");
xe->window = (Window)0; // not used.
xe->window = (Window)0;
temp = S48_RECORD_REF(e, 4);
for (i = 0; i < 32; i++) {
int j; char* b = &xe->key_vector[i];

View File

@ -53,13 +53,14 @@ s48_value scx_Send_Event(s48_value display, s48_value window,
s48_value propagate,
s48_value event_mask, s48_value event) {
XEvent e;
Status r;
scx_extract_event(event, &e);
Status r = XSendEvent(scx_extract_display(display),
scx_extract_window(window),
S48_EXTRACT_BOOLEAN(propagate),
scx_extract_event_mask(event_mask),
&e);
r = XSendEvent(scx_extract_display(display),
scx_extract_window(window),
S48_EXTRACT_BOOLEAN(propagate),
scx_extract_event_mask(event_mask),
&e);
return r ? S48_TRUE : S48_FALSE;
}
@ -68,7 +69,7 @@ s48_value scx_add_pending_channel(channel) {
S48_CHECK_CHANNEL(channel);
socket_fd = S48_UNSAFE_EXTRACT_FIXNUM(S48_UNSAFE_CHANNEL_OS_INDEX(channel));
if (! s48_add_pending_fd(socket_fd, 1)) // 1 for: yes, is input
if (! s48_add_pending_fd(socket_fd, 1)) /* 1 for: yes, is input */
s48_raise_out_of_memory_error();
return S48_UNSPECIFIC;

View File

@ -72,7 +72,7 @@ s48_value scx_List_Fonts_With_Info(s48_value display, s48_value pattern,
res = s48_cons(cell, res);
}
S48_GC_UNPROTECT();
XFreeFontNames(fonts); // FontStructs have to be freed later
XFreeFontNames(fonts); /* FontStructs have to be freed later */
return res;
}
@ -95,7 +95,6 @@ s48_value scx_Get_Font_Path(s48_value display) {
s48_value res = S48_NULL;
S48_DECLARE_GC_PROTECT(1);
// Enable/Disable Interrupts ??
sa = XGetFontPath(scx_extract_display(display), &n);
S48_GC_PROTECT_1(res);

View File

@ -290,7 +290,6 @@ s48_value scx_Set_Dashes(s48_value display, s48_value gc, s48_value dashoffset,
s48_value scx_Set_Clip_Rectangles(s48_value display, s48_value gc,
s48_value x_origin, s48_value y_origin,
s48_value rects, s48_value ordering) {
//TODO
int i, n = s48_list_length(rects);
XRectangle crects[n];
for (i = 0; i < n; i++) {

View File

@ -71,8 +71,10 @@ void scx_init_xlib(void) {
}
//#if defined(XLIB_RELEASE_5_OR_LATER) && (defined(sun) || defined(__sun__)) &&\
// defined(__svr4__)
/*
#if defined(XLIB_RELEASE_5_OR_LATER) && (defined(sun) || defined(__sun__)) &&\
defined(__svr4__)
*/
/*
* Stub interface to dynamic linker routines
* that SunOS uses but didn't ship with 4.1.
@ -81,7 +83,9 @@ void scx_init_xlib(void) {
* load some routines using the dlsym interface, described in dlsym(3x).
* Unfortunately SunOS 4.1 does not include the necessary library, libdl.
*/
//void *dlopen() { return 0; }
//void *dlsym() { return 0; }
//int dlclose() { return -1; }
//#endif
/*
void *dlopen() { return 0; }
void *dlsym() { return 0; }
int dlclose() { return -1; }
#endif
*/

View File

@ -86,7 +86,7 @@ s48_value scx_Set_Modifier_Mapping(s48_value display, s48_value modmap) {
s48_value l2 = S48_CDR(S48_CAR(l));
int j = 0;
for (j = 0; j < max; j++) {
if ((mod < 0) || (mod > 7)) continue; // TODO: error??
if ((mod < 0) || (mod > 7)) continue; /* TODO: error?? */
if (l2 != S48_NULL) {
ks[mod*max + j] = s48_extract_integer(S48_CAR(l2));
l2 = S48_CDR(l2);

View File

@ -141,7 +141,7 @@ s48_value scx_enter_property(Atom type, int format, char* data,
l = s48_cons(s48_enter_integer(((long*)data)[i]), l);
S48_RECORD_SET(p, 2, l);
break;
default: // should not be possible
default: /* should not be possible */
S48_RECORD_SET(p, 1, s48_enter_integer(format));
S48_RECORD_SET(p, 2, S48_FALSE);
}
@ -176,7 +176,7 @@ s48_value scx_Get_Window_Property(s48_value display, s48_value window,
S48_GC_UNPROTECT();
return res;
} else
// Property does not exists
/* Property does not exists */
return S48_FALSE;
}

View File

@ -48,7 +48,7 @@ void scx_extract_text_item(s48_value v, XTextItem* ti) {
}
ti->delta = s48_extract_integer(S48_RECORD_REF(v, 1));
ti->font = scx_extract_font(S48_RECORD_REF(v, 2));
// Free all chars arrays!
/* Free all chars arrays! */
}
void scx_extract_text_item_16(s48_value v, XTextItem16* ti) {
@ -70,7 +70,7 @@ void scx_extract_text_item_16(s48_value v, XTextItem16* ti) {
ti->delta = s48_extract_integer(S48_RECORD_REF(v, 1));
ti->font = scx_extract_font(S48_RECORD_REF(v, 2));
}
// Free all chars arrays!
/* Free all chars arrays! */
}
s48_value scx_Draw_Text(s48_value display, s48_value drawable,

View File

@ -17,6 +17,16 @@ int s48_list_length(s48_value list) {
return res;
}
extern unsigned long s48_extract_enum_set(s48_value v, char* typestr) {
s48_value enum_set_type = s48_get_imported_binding("s48-enum-set-type");
s48_value type = s48_get_imported_binding(typestr);
s48_check_record_type(v, enum_set_type);
if (S48_UNSAFE_SHARED_BINDING_REF(type) !=
S48_UNSAFE_RECORD_REF(v, 0))
s48_raise_argument_type_error(v);
return s48_extract_integer(S48_UNSAFE_RECORD_REF(v, 1));
}
s48_value s48_enter_enum_set(unsigned long v, char* typestr) {
s48_value r = s48_make_record(s48_get_imported_binding("s48-enum-set-type"));
S48_DECLARE_GC_PROTECT(1);
@ -44,13 +54,13 @@ void scx_struct_cache_set(void* cpointer, s48_value* l, s48_value v) {
S48_DECLARE_GC_PROTECT(3);
S48_GC_PROTECT_3(list, pair, previous);
// create the new entry
/* create the new entry */
pair = s48_make_weak_pointer(v);
pair = s48_cons(S48_ENTER_POINTER(cpointer), pair);
*l = s48_cons(pair, *l);
previous = *l;
// remove all empty and duplicate entries
/* remove all empty and duplicate entries */
while (list != S48_NULL) {
s48_value entry = S48_CAR(list);
if ((S48_WEAK_POINTER_REF(S48_CDR(entry)) == S48_FALSE) ||

View File

@ -39,9 +39,6 @@ s48_value scx_Parse_Geometry(s48_value strg) {
return ret;
}
// scx_Parse_Color is in colormap.c
void scx_init_util(void) {
S48_EXPORT_FUNCTION(scx_Get_Default);
S48_EXPORT_FUNCTION(scx_Resource_Manager_String);

View File

@ -25,7 +25,7 @@
#define S48_NULL_P(x) S48_EQ(x, S48_NULL)
#define S48_INTEGER_P(x) (S48_FIXNUM_P(x) || S48_BIGNUM_P(x))
// TODO: S48_x_POINTER already exitst ?!
/* TODO: S48_x_POINTER already exitst ?!*/
#define S48_POINTER_P(x) S48_INTEGER_P(x)
#define S48_ENTER_POINTER(x) s48_enter_integer((long)x)
#define S48_EXTRACT_POINTER(x) (void*)s48_extract_integer(x)
@ -38,18 +38,16 @@ extern int s48_list_length(s48_value list);
#define S48_EXTRACT_ENUM(x, typestr) \
s48_extract_integer(s48_checked_record_ref(x, 1, \
s48_get_imported_binding(typestr)))
// S48_SHARED_BINDING_REF(s48_get_imported_binding(typestr))))
#define S48_ENTER_ENUM(index, vvectorstr) \
S48_VECTOR_REF(S48_SHARED_BINDING_REF(s48_get_imported_binding(vvectorstr)),\
index)
#define S48_EXTRACT_ENUM_SET(x, typestr) \
s48_extract_integer(s48_checked_record_ref(x, 1, \
s48_get_imported_binding("s48-enum-set-type")))
// TODO check type in record-field 0
#define S48_EXTRACT_ENUM_SET(x, typestr) s48_extract_enum_set(x, typestr)
extern unsigned long s48_extract_enum_set(s48_value v, char* typestr);
extern s48_value s48_enter_enum_set(unsigned long v, char* typestr);
// *** Extraction-Macros for the XIDs ********************************
/*** Extraction-Macros for the XIDs ********************************/
#define scx_extract_window(x) (Window)s48_extract_integer(x)
#define scx_enter_window(x) s48_enter_integer((long)x)
@ -68,7 +66,7 @@ extern s48_value s48_enter_enum_set(unsigned long v, char* typestr);
#define scx_extract_keysym(x) (GContext)s48_extract_integer(x)
#define scx_enter_keysym(x) s48_enter_integer((long)x)
// other CARD32
/* other CARD32 */
#define scx_enter_atom(x) s48_enter_integer((long)x)
#define scx_extract_atom(x) (Atom)s48_extract_integer(x)
@ -77,14 +75,14 @@ extern s48_value s48_enter_enum_set(unsigned long v, char* typestr);
#define scx_enter_time(x) s48_enter_integer(x)
#define scx_extract_time(x) (Time)s48_extract_integer(x)
// other ints
/* other ints */
#define scx_enter_keycode(x) s48_enter_fixnum(x)
#define scx_extract_keycode(x) (KeyCode)s48_extract_integer(x)
#define scx_extract_pixel(x) (Pixel)s48_extract_integer(x)
#define scx_enter_pixel(x) s48_enter_integer((long)x)
// records
/* records */
#define scx_display s48_get_imported_binding("scx-display")
#define scx_extract_display(x) \
@ -140,10 +138,7 @@ extern unsigned long scx_extract_window_changes(s48_value changes,
extern s48_value scx_enter_x_error(XErrorEvent* xe);
extern void scx_extract_x_error(s48_value e, XErrorEvent* xe);
//#define scx_enter_REGION(x) s48_enter_integer((long)x)
//#define scx_extract_REGION(x) (Region)s48_extract_integer(x)
// more types
/* more types */
#define scx_extract_state(x) S48_EXTRACT_ENUM(x, "scx-state")
#define scx_enter_state(x) S48_ENTER_ENUM(x, "scx-states")