Mercurial > hg > xemacs-beta
comparison src/emodules.c @ 4956:3461165c79be
fix compile errors due to mismatched string pointer types
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-01-28 Ben Wing <ben@xemacs.org>
* device-x.c (x_init_device):
* emodules.c (emodules_load):
* emodules.c (emodules_doc_subr):
* emodules.c (emodules_doc_sym):
* emodules.h:
Make the externally-called functions emodules_doc_sym() and
emodules_doc_subr() take Ascbyte * pointers since they're usually
passed string constants and we can't guarantee the encoding if
it's not ASCII. Fix pointer type in calls to dll_variable(), etc.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Thu, 28 Jan 2010 01:15:10 -0600 |
parents | 304aebb79cd3 |
children | 16112448d484 4aebb0131297 |
comparison
equal
deleted
inserted
replaced
4955:de64354ffcbf | 4956:3461165c79be |
---|---|
373 if (dlhandle == NULL) | 373 if (dlhandle == NULL) |
374 { | 374 { |
375 signal_error (Qdll_error, "Opening dynamic module", dll_error ()); | 375 signal_error (Qdll_error, "Opening dynamic module", dll_error ()); |
376 } | 376 } |
377 | 377 |
378 ellcc_rev = (const long *) dll_variable (dlhandle, "emodule_compiler"); | 378 ellcc_rev = (const long *) dll_variable (dlhandle, |
379 (const Ibyte *) "emodule_compiler"); | |
379 if (ellcc_rev == NULL || *ellcc_rev <= 0L) | 380 if (ellcc_rev == NULL || *ellcc_rev <= 0L) |
380 signal_error (Qdll_error, "Invalid dynamic module: Missing symbol `emodule_compiler'", Qunbound); | 381 signal_error (Qdll_error, "Invalid dynamic module: Missing symbol `emodule_compiler'", Qunbound); |
381 if (*ellcc_rev > EMODULES_REVISION) | 382 if (*ellcc_rev > EMODULES_REVISION) |
382 signal_ferror (Qdll_error, "Invalid dynamic module: Unsupported version `%ld(%ld)'", *ellcc_rev, EMODULES_REVISION); | 383 signal_ferror (Qdll_error, "Invalid dynamic module: Unsupported version `%ld(%ld)'", *ellcc_rev, EMODULES_REVISION); |
383 | 384 |
384 f = (const Extbyte **) dll_variable (dlhandle, "emodule_name"); | 385 f = (const Extbyte **) dll_variable (dlhandle, |
386 (const Ibyte *) "emodule_name"); | |
385 if (f == NULL || *f == NULL) | 387 if (f == NULL || *f == NULL) |
386 signal_error (Qdll_error, "Invalid dynamic module: Missing symbol `emodule_name'", Qunbound); | 388 signal_error (Qdll_error, "Invalid dynamic module: Missing symbol `emodule_name'", Qunbound); |
387 | 389 |
388 mname = NEW_EXTERNAL_TO_C_STRING (f, Qemodule_string_encoding); | 390 mname = NEW_EXTERNAL_TO_C_STRING (f, Qemodule_string_encoding); |
389 /* #### Not obvious we have to force an alloca copy here, but the old | 391 /* #### Not obvious we have to force an alloca copy here, but the old |
391 IBYTE_STRING_TO_ALLOCA (mname, mname); | 393 IBYTE_STRING_TO_ALLOCA (mname, mname); |
392 | 394 |
393 if (mname[0] == '\0') | 395 if (mname[0] == '\0') |
394 signal_error (Qdll_error, "Invalid dynamic module: Empty value for `emodule_name'", Qunbound); | 396 signal_error (Qdll_error, "Invalid dynamic module: Empty value for `emodule_name'", Qunbound); |
395 | 397 |
396 f = (const Extbyte **) dll_variable (dlhandle, "emodule_version"); | 398 f = (const Extbyte **) dll_variable (dlhandle, |
399 (const Ibyte *) "emodule_version"); | |
397 if (f == NULL || *f == NULL) | 400 if (f == NULL || *f == NULL) |
398 signal_error (Qdll_error, "Missing symbol `emodule_version': Invalid dynamic module", Qunbound); | 401 signal_error (Qdll_error, "Missing symbol `emodule_version': Invalid dynamic module", Qunbound); |
399 | 402 |
400 mver = NEW_EXTERNAL_TO_C_STRING (f, Qemodule_string_encoding); | 403 mver = NEW_EXTERNAL_TO_C_STRING (f, Qemodule_string_encoding); |
401 /* #### Not obvious we have to force an alloca copy here, but the old | 404 /* #### Not obvious we have to force an alloca copy here, but the old |
402 code did so */ | 405 code did so */ |
403 IBYTE_STRING_TO_ALLOCA (mver, mver); | 406 IBYTE_STRING_TO_ALLOCA (mver, mver); |
404 | 407 |
405 f = (const Extbyte **) dll_variable (dlhandle, "emodule_title"); | 408 f = (const Extbyte **) dll_variable (dlhandle, |
409 (const Ibyte *) "emodule_title"); | |
406 if (f == NULL || *f == NULL) | 410 if (f == NULL || *f == NULL) |
407 signal_error (Qdll_error, "Invalid dynamic module: Missing symbol `emodule_title'", Qunbound); | 411 signal_error (Qdll_error, "Invalid dynamic module: Missing symbol `emodule_title'", Qunbound); |
408 | 412 |
409 mtitle = NEW_EXTERNAL_TO_C_STRING (f, Qemodule_string_encoding); | 413 mtitle = NEW_EXTERNAL_TO_C_STRING (f, Qemodule_string_encoding); |
410 /* #### Not obvious we have to force an alloca copy here, but the old | 414 /* #### Not obvious we have to force an alloca copy here, but the old |
526 modules[x].used = 1; | 530 modules[x].used = 1; |
527 } | 531 } |
528 } | 532 } |
529 | 533 |
530 void | 534 void |
531 emodules_doc_subr (const Ibyte *symname, const Ibyte *doc) | 535 emodules_doc_subr (const Ascbyte *symname, const Ascbyte *doc) |
532 { | 536 { |
533 Bytecount len = qxestrlen (symname); | 537 Bytecount len; |
534 Lisp_Object sym = oblookup (Vobarray, symname, len); | 538 Lisp_Object sym; |
535 Lisp_Subr *subr; | 539 Lisp_Subr *subr; |
536 | 540 |
541 ASSERT_ASCTEXT_ASCII (symname); | |
542 len = strlen (symname); | |
543 sym = oblookup (Vobarray, (const Ibyte *) symname, len); | |
544 | |
545 /* We do this assert to avoid the possibility of externally formatted | |
546 text ending up in the doc string, where it could cause crashes. | |
547 It you need to have a non-ASCII doc string, create another version | |
548 emodules_doc_subr_istring() that accepts an Ibyte * and doesn't | |
549 assert, or create an emodules_doc_subr_extstring() that takes | |
550 an externally_formatted string and a coding system name. */ | |
551 ASSERT_ASCTEXT_ASCII (doc); | |
537 /* Skip autoload cookies */ | 552 /* Skip autoload cookies */ |
538 if (SYMBOLP (sym) && SUBRP (XSYMBOL (sym)->function)) | 553 if (SYMBOLP (sym) && SUBRP (XSYMBOL (sym)->function)) |
539 { | 554 { |
540 subr = XSUBR (XSYMBOL (sym)->function); | 555 subr = XSUBR (XSYMBOL (sym)->function); |
541 subr->doc = xstrdup (doc); | 556 subr->doc = xstrdup (doc); |
547 * look into this? | 562 * look into this? |
548 */ | 563 */ |
549 } | 564 } |
550 | 565 |
551 void | 566 void |
552 emodules_doc_sym (const Ibyte *symname, const Ibyte *doc) | 567 emodules_doc_sym (const Ascbyte *symname, const Ascbyte *doc) |
553 { | 568 { |
554 Bytecount len = qxestrlen (symname); | 569 Bytecount len; |
555 Lisp_Object sym = oblookup (Vobarray, symname, len); | 570 Lisp_Object sym; |
556 Lisp_Object docstr; | 571 Lisp_Object docstr; |
557 struct gcpro gcpro1; | 572 struct gcpro gcpro1; |
558 | 573 |
574 ASSERT_ASCTEXT_ASCII (symname); | |
575 len = strlen (symname); | |
576 sym = oblookup (Vobarray, (const Ibyte *) symname, len); | |
577 | |
578 /* See comments above in emodules_doc_subr() about why we assert like | |
579 this. */ | |
580 ASSERT_ASCTEXT_ASCII (doc); | |
559 if (SYMBOLP (sym)) | 581 if (SYMBOLP (sym)) |
560 { | 582 { |
561 docstr = build_istring (doc); | 583 docstr = build_ascstring (doc); |
562 GCPRO1 (docstr); | 584 GCPRO1 (docstr); |
563 Fput (sym, Qvariable_documentation, docstr); | 585 Fput (sym, Qvariable_documentation, docstr); |
564 UNGCPRO; | 586 UNGCPRO; |
565 } | 587 } |
566 } | 588 } |