1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458
|
/* $XConsortium: MultiSrc.c,v 1.8 95/01/24 22:29:08 kaleb Exp $ */
/*
* Copyright 1991 by OMRON Corporation
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name OMRON not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. OMRON makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Authors: Chris Peterson MIT X Consortium
* Li Yuhong OMRON Corporation
* Frank Sheeran OMRON Corporation
*
* Much code taken from X11R3 String and Disk Sources.
*/
/*
Copyright (c) 1991, 1994 X Consortium
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.
*/
/*
* MultiSrc.c - MultiSrc object. (For use with the text widget).
*
*/
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xfuncs.h>
#include <X11/neXtaw/XawInit.h>
#include <X11/neXtaw/MultiSrcP.h>
#include <X11/neXtaw/XawImP.h>
#include <X11/Xmu/Misc.h>
#include <X11/Xmu/CharSet.h>
#include "XawI18n.h"
#include <X11/Xos.h>
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
/****************************************************************
*
* Full class record constant
*
****************************************************************/
/* Private Data */
static int magic_value = MAGIC_VALUE;
#define offset(field) XtOffsetOf(MultiSrcRec, multi_src.field)
static XtResource resources[] = {
{XtNstring, XtCString, XtRString, sizeof (XtPointer),
offset(string), XtRPointer, NULL},
{XtNtype, XtCType, XtRMultiType, sizeof (XawAsciiType),
offset(type), XtRImmediate, (XtPointer)XawAsciiString},
/* not used. */
{XtNdataCompression, XtCDataCompression, XtRBoolean, sizeof (Boolean),
offset(data_compression), XtRImmediate, (XtPointer) FALSE},
{XtNpieceSize, XtCPieceSize, XtRInt, sizeof (XawTextPosition),
offset(piece_size), XtRImmediate, (XtPointer) BUFSIZ},
{XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer),
offset(callback), XtRCallback, (XtPointer)NULL},
{XtNuseStringInPlace, XtCUseStringInPlace, XtRBoolean, sizeof (Boolean),
offset(use_string_in_place), XtRImmediate, (XtPointer) FALSE},
{XtNlength, XtCLength, XtRInt, sizeof (int),
offset(multi_length), XtRInt, (XtPointer) &magic_value},
};
#undef offset
static XawTextPosition Scan(), Search(), ReadText();
static int ReplaceText();
static MultiPiece * FindPiece(), * AllocNewPiece();
static FILE * InitStringOrFile();
static void FreeAllPieces(), RemovePiece(), BreakPiece(), LoadPieces();
static void RemoveOldStringOrFile(), CvtStringToMultiType();
static void ClassInitialize(), Initialize(), Destroy(), GetValuesHook();
static String StorePiecesInString();
static Boolean SetValues(), WriteToFile();
#define MyWStrncpy( t,s,wcnt ) (void) memmove( (t), (s), (wcnt)*sizeof(wchar_t))
#ifndef MyWStrncpy
static void (MyWStrncpy)();
#endif
extern char *tmpnam();
#ifdef X_NOT_STDC_ENV
extern int errno;
#endif
#ifdef X_NOT_POSIX
#define Off_t long
#define Size_t unsigned int
#else
#define Off_t off_t
#define Size_t size_t
#endif
extern wchar_t* _XawTextMBToWC();
extern char *_XawTextWCToMB();
#define superclass (&textSrcClassRec)
MultiSrcClassRec multiSrcClassRec = {
{ /* object_class fields */
/* superclass */ (WidgetClass) superclass,
/* class_name */ "MultiSrc",
/* widget_size */ sizeof(MultiSrcRec),
/* class_initialize */ ClassInitialize,
/* class_part_initialize */ NULL,
/* class_inited */ FALSE,
/* initialize */ Initialize,
/* initialize_hook */ NULL,
/* pad */ NULL,
/* pad */ NULL,
/* pad */ 0,
/* resources */ resources,
/* num_resources */ XtNumber(resources),
/* xrm_class */ NULLQUARK,
/* pad */ FALSE,
/* pad */ FALSE,
/* pad */ FALSE,
/* pad */ FALSE,
/* destroy */ Destroy,
/* pad */ NULL,
/* pad */ NULL,
/* set_values */ SetValues,
/* set_values_hook */ NULL,
/* pad */ NULL,
/* get_values_hook */ GetValuesHook,
/* pad */ NULL,
/* version */ XtVersion,
/* callback_private */ NULL,
/* pad */ NULL,
/* pad */ NULL,
/* pad */ NULL,
/* extension */ NULL
},
{ /* textSrc_class fields */
/* Read */ ReadText,
/* Replace */ ReplaceText,
/* Scan */ Scan,
/* Search */ Search,
/* SetSelection */ XtInheritSetSelection,
/* ConvertSelection */ XtInheritConvertSelection
},
{ /* multiSrc_class fields */
/* Keep the compiler happy */ '\0'
}
};
WidgetClass multiSrcObjectClass = (WidgetClass)&multiSrcClassRec;
/************************************************************
*
* Semi-Public Interfaces.
*
************************************************************/
/* Function Name: ClassInitialize
* Description: Class Initialize routine, called only once.
* Arguments: none.
* Returns: none.
*/
static void
ClassInitialize()
{
XawInitializeWidgetSet();
XtAddConverter( XtRString, XtRMultiType, CvtStringToMultiType,
NULL, (Cardinal) 0);
}
/* Function Name: Initialize
* Description: Initializes the simple menu widget
* Arguments: request - the widget requested by the argument list.
* new - the new widget with both resource and non
* resource values.
* Returns: none.
*/
/* ARGSUSED */
static void
Initialize(request, new, args, num_args)
Widget request, new;
ArgList args;
Cardinal* num_args;
{
MultiSrcObject src = (MultiSrcObject) new;
FILE * file;
/*
* Set correct flags (override resources) depending upon widget class.
*/
src->multi_src.changes = FALSE;
src->multi_src.allocated_string = FALSE;
file = InitStringOrFile(src, src->multi_src.type == XawAsciiFile);
LoadPieces(src, file, NULL);
if (file != NULL) fclose(file);
src->text_src.text_format = XawFmtWide;
}
/* Function Name: ReadText
* Description: This function reads the source.
* Arguments: w - the MultiSource widget.
* pos - position of the text to retreive.
* RETURNED text - text block that will contain returned text.
* length - maximum number of characters to read.
* Returns: The number of characters read into the buffer.
*/
static XawTextPosition
ReadText(w, pos, text, length)
Widget w;
XawTextPosition pos;
XawTextBlock* text;
int length;
{
MultiSrcObject src = (MultiSrcObject) w;
XawTextPosition count, start;
MultiPiece * piece = FindPiece(src, pos, &start);
text->format = XawFmtWide;
text->firstPos = pos;
text->ptr = (char *)(piece->text + (pos - start));
count = piece->used - (pos - start);
text->length = (length > count) ? count : length;
return(pos + text->length);
}
/* Function Name: ReplaceText.
* Description: Replaces a block of text with new text.
* Arguments: w - the MultiSource widget.
* startPos, endPos - ends of text that will be removed.
* text - new text to be inserted into buffer at startPos.
* Returns: XawEditError or XawEditDone.
*/
/*ARGSUSED*/
static int
ReplaceText( w, startPos, endPos, u_text_p)
Widget w;
XawTextPosition startPos, endPos;
XawTextBlock* u_text_p;
{
MultiSrcObject src = (MultiSrcObject) w;
MultiPiece *start_piece, *end_piece, *temp_piece;
XawTextPosition start_first, end_first;
int length, firstPos;
wchar_t *wptr;
Boolean local_artificial_block = False;
XawTextBlock text;
/* STEP 1: The user handed me a text block called `u_text' that may be
* in either FMTWIDE or FMT8BIT (ie MB.) Later code needs the block
* `text' to hold FMTWIDE. So, this copies `u_text' to `text', and if
* `u_text' was MB, I knock it up to WIDE. */
if ( u_text_p->length == 0 ) /* if so, the block contents never ref'd. */
text.length = 0;
else if ( u_text_p->format == XawFmtWide) {
local_artificial_block = False; /* ie, don't have to free it ourselves*/
text.firstPos = u_text_p->firstPos;
text.length = u_text_p->length;
text.ptr = u_text_p->ptr;
/* text.format is unneeded */
} else {
/* WARNING! u_text->firstPos and length are in units of CHAR, not CHARACTERS! */
local_artificial_block = True; /* ie, have to free it ourselves */
text.firstPos = 0;
text.length = u_text_p->length; /* _XawTextMBToWC converts this to wchar len. */
text.ptr = (char*)_XawTextMBToWC( XtDisplay(XtParent(w)),
&(u_text_p->ptr[u_text_p->firstPos]), &(text.length) );
/* I assert the following assignment is not needed - since Step 4
depends on length, it has no need of a terminating NULL. I think
the ASCII-version has the same needless NULL. */
/*((wchar_t*)text.ptr)[ text.length ] = NULL;*/
}
/* STEP 2: some initialization... */
if (src->text_src.edit_mode == XawtextRead)
return(XawEditError);
start_piece = FindPiece(src, startPos, &start_first);
end_piece = FindPiece(src, endPos, &end_first);
/* STEP 3: remove the empty pieces... */
if (start_piece != end_piece) {
temp_piece = start_piece->next;
/* If empty and not the only piece then remove it. */
if ( ((start_piece->used = startPos - start_first) == 0) &&
!((start_piece->next == NULL) && (start_piece->prev == NULL)) )
RemovePiece(src, start_piece);
while (temp_piece != end_piece) {
temp_piece = temp_piece->next;
RemovePiece(src, temp_piece->prev);
}
end_piece->used -= endPos - end_first;
if (end_piece->used != 0)
MyWStrncpy(end_piece->text, (end_piece->text + endPos - end_first),
(int) end_piece->used);
}
else { /* We are fully in one piece. */
if ( (start_piece->used -= endPos - startPos) == 0) {
if ( !((start_piece->next == NULL) && (start_piece->prev == NULL)) )
RemovePiece(src, start_piece);
}
else {
MyWStrncpy(start_piece->text + (startPos - start_first),
start_piece->text + (endPos - start_first),
(int) (start_piece->used - (startPos - start_first)) );
if ( src->multi_src.use_string_in_place &&
((src->multi_src.length - (endPos - startPos)) <
(src->multi_src.piece_size - 1)) )
start_piece->text[src->multi_src.length - (endPos - startPos)] = (wchar_t)0;
}
}
src->multi_src.length += text.length -(endPos - startPos);
/*((TextWidget)src->object.parent)->text.lastPos = src->multi_src.length;*/
/* STEP 4: insert the new stuff */
if ( text.length != 0) {
start_piece = FindPiece(src, startPos, &start_first);
length = text.length;
firstPos = text.firstPos;
while (length > 0) {
wchar_t* ptr;
int fill;
if (src->multi_src.use_string_in_place) {
if (start_piece->used == (src->multi_src.piece_size - 1)) {
/*
* The string is used in place, then the string
* is not allowed to grow.
*/
start_piece->used = src->multi_src.length =
src->multi_src.piece_size - 1;
/*((TextWidget)src->object.parent)->text.lastPos = src->multi_src.length;*/
start_piece->text[src->multi_src.length] = (wchar_t)0;
return(XawEditError);
}
}
if (start_piece->used == src->multi_src.piece_size) {
BreakPiece(src, start_piece);
start_piece = FindPiece(src, startPos, &start_first);
}
fill = Min((int)(src->multi_src.piece_size - start_piece->used), length);
ptr = start_piece->text + (startPos - start_first);
MyWStrncpy(ptr + fill, ptr,
(int) start_piece->used - (startPos - start_first));
wptr =(wchar_t *)text.ptr;
(void)wcsncpy(ptr, wptr + firstPos, fill);
startPos += fill;
firstPos += fill;
start_piece->used += fill;
length -= fill;
}
}
if ( local_artificial_block == True )
/* In other words, text is not the u_text that the user handed me but
one I made myself. I only care, because I need to free the string. */
XtFree( text.ptr );
if (src->multi_src.use_string_in_place)
start_piece->text[start_piece->used] = (wchar_t)0;
src->multi_src.changes = TRUE;
XtCallCallbacks(w, XtNcallback, NULL);
return(XawEditDone);
}
/* Function Name: Scan
* Description: Scans the text source for the number and type
* of item specified.
* Arguments: w - the MultiSource widget.
* position - the position to start scanning.
* type - type of thing to scan for.
* dir - direction to scan.
* count - which occurance if this thing to search for.
* include - whether or not to include the character found in
* the position that is returned.
* Returns: the position of the item found.
*
* Note: While there are only 'n' characters in the file there are n+1
* possible cursor positions (one before the first character and
* one after the last character.
*/
static
XawTextPosition
Scan( w, position, type, dir, count, include )
Widget w;
XawTextPosition position;
XawTextScanType type;
XawTextScanDirection dir;
int count;
Boolean include;
{
MultiSrcObject src = (MultiSrcObject) w;
int inc;
MultiPiece * piece;
XawTextPosition first, first_eol_position = 0;
wchar_t * ptr;
if (type == XawstAll) { /* Optimize this common case. */
if (dir == XawsdRight)
return(src->multi_src.length);
return(0); /* else. */
}
/* STEP 1: basic sanity checks */
if (position > src->multi_src.length)
position = src->multi_src.length;
if ( dir == XawsdRight ) {
if (position == src->multi_src.length)
return(src->multi_src.length);
inc = 1;
}
else {
if (position == 0)
return(0);
inc = -1;
position--;
}
piece = FindPiece(src, position, &first);
if ( piece->used == 0 ) return(0); /* i.e., buffer is empty. */
ptr = (position - first) + piece->text;
switch (type) {
case XawstEOL:
case XawstParagraph:
case XawstWhiteSpace:
for ( ; count > 0 ; count-- ) {
Boolean non_space = FALSE, first_eol = TRUE;
/* CONSTCOND */
while (TRUE) {
wchar_t c = *ptr;
ptr += inc;
position += inc;
if (type == XawstWhiteSpace) {
if (iswspace(c)) {
if (non_space)
break;
}
else
non_space = TRUE;
}
else if (type == XawstEOL) {
if (c == _Xaw_atowc(XawLF)) break;
}
else { /* XawstParagraph */
if (first_eol) {
if (c == _Xaw_atowc(XawLF)) {
first_eol_position = position;
first_eol = FALSE;
}
}
else
if ( c == _Xaw_atowc(XawLF))
break;
else if ( !iswspace(c) )
first_eol = TRUE;
}
if ( ptr < piece->text ) {
piece = piece->prev;
if (piece == NULL) /* Begining of text. */
return(0);
ptr = piece->text + piece->used - 1;
}
else if ( ptr >= (piece->text + piece->used) ) {
piece = piece->next;
if (piece == NULL) /* End of text. */
return(src->multi_src.length);
ptr = piece->text;
}
}
}
if (!include) {
if ( type == XawstParagraph)
position = first_eol_position;
position -= inc;
}
break;
case XawstPositions:
position += count * inc;
break;
case XawstAll: /* handled in special code above */
default:
break;
}
if ( dir == XawsdLeft )
position++;
if (position >= src->multi_src.length)
return(src->multi_src.length);
if (position < 0)
return(0);
return(position);
}
/* Function Name: Search
* Description: Searchs the text source for the text block passed
* Arguments: w - the MultiSource Widget.
* position - the position to start scanning.
* dir - direction to scan.
* text - the text block to search for.
* Returns: the position of the item found.
*/
static XawTextPosition
Search(w, position, dir, text )
Widget w;
XawTextPosition position;
XawTextScanDirection dir;
XawTextBlock* text;
{
MultiSrcObject src = (MultiSrcObject) w;
int inc, count = 0;
wchar_t * ptr;
wchar_t* wtarget;
int wtarget_len;
Display * d = XtDisplay(XtParent(w));
MultiPiece * piece;
wchar_t* buf;
XawTextPosition first;
/* STEP 1: First, a brief sanity check. */
if ( dir == XawsdRight )
inc = 1;
else {
inc = -1;
if (position == 0)
return(XawTextSearchError); /* scanning left from 0??? */
position--;
}
/* STEP 2: Ensure I have a local wide string.. */
/* Since this widget stores 32bit chars, I check here to see if
I'm being passed a string claiming to be 8bit chars (ie, MB text.)
If that is the case, naturally I convert to 32bit format. */
/*if the block was FMT8BIT, length will convert to REAL wchar count below */
wtarget_len = text->length;
if ( text->format == XawFmtWide )
wtarget = &( ((wchar_t*)text->ptr) [text->firstPos] );
else
{
/* The following converts wtarget_len from byte len to wchar count */
wtarget = _XawTextMBToWC( d, &text->ptr[ text->firstPos ], &wtarget_len );
}
/* OK, I can now assert that wtarget holds wide characters, wtarget_len
holds an accurate count of those characters, and that firstPos has been
effectively factored out of the following computations. */
/* STEP 3: SEARCH! */
buf = (wchar_t *)XtMalloc((unsigned)sizeof(wchar_t) * wtarget_len );
(void)wcsncpy(buf, wtarget, wtarget_len );
piece = FindPiece(src, position, &first);
ptr = (position - first) + piece->text;
/* CONSTCOND */
while (TRUE) {
if (*ptr == ((dir == XawsdRight) ? *(buf + count)
: *(buf + wtarget_len - count - 1)) ) {
if (count == (text->length - 1))
break;
else
count++;
}
else {
if (count != 0) {
position -=inc * count;
ptr -= inc * count;
}
count = 0;
}
ptr += inc;
position += inc;
while ( ptr < piece->text ) {
piece = piece->prev;
if (piece == NULL) { /* Begining of text. */
XtFree((char *)buf);
return(XawTextSearchError);
}
ptr = piece->text + piece->used - 1;
}
while ( ptr >= (piece->text + piece->used) ) {
piece = piece->next;
if (piece == NULL) { /* End of text. */
XtFree((char *)buf);
return(XawTextSearchError);
}
ptr = piece->text;
}
}
XtFree( (char *) buf );
if (dir == XawsdLeft)
return( position );
return( position - ( wtarget_len - 1 ) );
}
/* Function Name: SetValues
* Description: Sets the values for the MultiSource.
* Arguments: current - current state of the widget.
* request - what was requested.
* new - what the widget will become.
* Returns: True if redisplay is needed.
*/
/* ARGSUSED */
static Boolean
SetValues(current, request, new, args, num_args)
Widget current, request, new;
ArgList args;
Cardinal* num_args;
{
MultiSrcObject src = (MultiSrcObject) new;
MultiSrcObject old_src = (MultiSrcObject) current;
XtAppContext app_con = XtWidgetToApplicationContext(new);
Boolean total_reset = FALSE, string_set = FALSE;
FILE * file;
int i;
if ( old_src->multi_src.use_string_in_place !=
src->multi_src.use_string_in_place ) {
XtAppWarning( app_con,
"MultiSrc: The XtNuseStringInPlace resources may not be changed.");
src->multi_src.use_string_in_place =
old_src->multi_src.use_string_in_place;
}
for (i = 0; i < *num_args ; i++ )
if (streq(args[i].name, XtNstring)) {
string_set = TRUE;
break;
}
if ( string_set || (old_src->multi_src.type != src->multi_src.type) ) {
RemoveOldStringOrFile(old_src, string_set);
file = InitStringOrFile(src, string_set);
/* Load pieces does this logic for us, but it shouldn't. Its messy.*/
/*if (old_src->multi_src.type == XawAsciiString)
LoadPieces(src, NULL, src->multi_src.string);
else*/
LoadPieces(src, file, NULL);
if (file != NULL) fclose(file);
XawTextSetSource( XtParent(new), new, 0); /* Tell text widget
what happened. */
total_reset = TRUE;
}
if ( old_src->multi_src.multi_length != src->multi_src.multi_length )
src->multi_src.piece_size = src->multi_src.multi_length;
if ( !total_reset && (old_src->multi_src.piece_size
!= src->multi_src.piece_size) ) {
String mb_string = StorePiecesInString( old_src );
if ( mb_string != 0 ) {
FreeAllPieces( old_src );
LoadPieces( src, NULL, mb_string );
XtFree( mb_string );
} else {
/* If the buffer holds bad chars, don't touch it... */
XtAppWarningMsg( app_con,
"convertError", "multiSource", "XawError",
XtName( XtParent( (Widget) old_src ) ), NULL, NULL );
XtAppWarningMsg( app_con,
"convertError", "multiSource", "XawError",
"Non-character code(s) in buffer.", NULL, NULL );
}
}
return(FALSE);
}
/* Function Name: GetValuesHook
* Description: This is a get values hook routine that sets the
* values specific to the multi source.
* Arguments: w - the MultiSource Widget.
* args - the argument list.
* num_args - the number of args.
* Returns: none.
*/
static void
GetValuesHook(w, args, num_args)
Widget w;
ArgList args;
Cardinal* num_args;
{
MultiSrcObject src = (MultiSrcObject) w;
int i;
if (src->multi_src.type == XawAsciiString) {
for (i = 0; i < *num_args ; i++ )
if (streq(args[i].name, XtNstring)) {
if (src->multi_src.use_string_in_place) {
*((char **) args[i].value) = (char *)
src->multi_src.first_piece->text;
}
else {
if (_XawMultiSave(w)) /* If save sucessful. */
*((char **) args[i].value) = src->multi_src.string;
}
break;
}
}
}
/* Function Name: Destroy
* Description: Destroys an multi source (frees all data)
* Arguments: src - the Multi source Widget to free.
* Returns: none.
*/
static void
Destroy (w)
Widget w;
{
RemoveOldStringOrFile((MultiSrcObject) w, True);
}
/************************************************************
*
* Public routines
*
************************************************************/
/* Function Name: XawMultiSourceFreeString
* Description: Frees the string returned by a get values call
* on the string when the source is of type string.
* Arguments: w - the MultiSrc widget.
* Returns: none.
*
* The public interface is XawAsciiSourceFreeString!
*/
void
#if NeedFunctionPrototypes
_XawMultiSourceFreeString(
Widget w)
#else
_XawMultiSourceFreeString(w)
Widget w;
#endif
{
MultiSrcObject src = (MultiSrcObject) w;
/*if (src->multi_src.allocated_string&& src->multi_src.type != XawAsciiFile) {*/
/* ASSERT: src->multi_src.allocated_string -> we MUST free .string! */
if ( src->multi_src.allocated_string ) {
XtFree(src->multi_src.string);
src->multi_src.allocated_string = FALSE;
src->multi_src.string = NULL;
}
}
/* Function Name: _XawMultiSave
* Description: Saves all the pieces into a file or string as required.
* Arguments: w - the multiSrc Widget.
* Returns: TRUE if the save was successful.
*
* The public interface is XawAsciiSave(w)!
*/
Boolean
#if NeedFunctionPrototypes
_XawMultiSave(
Widget w)
#else
_XawMultiSave(w)
Widget w;
#endif
{
MultiSrcObject src = (MultiSrcObject) w;
XtAppContext app_con = XtWidgetToApplicationContext(w);
char * mb_string;
/*
* If using the string in place then there is no need to play games
* to get the internal info into a readable string.
*/
if (src->multi_src.use_string_in_place)
return(TRUE);
if (src->multi_src.type == XawAsciiFile) {
if (!src->multi_src.changes) /* No changes to save. */
return(TRUE);
mb_string = StorePiecesInString( src );
if ( mb_string != 0 ) {
if ( WriteToFile( mb_string, src->multi_src.string ) == FALSE ) {
XtFree( mb_string );
return( FALSE );
}
XtFree( mb_string );
src->multi_src.changes = FALSE;
return( TRUE );
} else {
/* If the buffer holds bad chars, don't touch it... */
XtAppWarningMsg( app_con,
"convertError", "multiSource", "XawError",
"Due to illegal characters, file not saved.", NULL, NULL);
return( FALSE );
}
}
else {
/* THIS FUNCTIONALITY IS UNDOCUMENTED, probably UNNEEDED? The manual
says this routine's only function is to save files to disk. -Sheeran */
mb_string = StorePiecesInString( src );
if ( mb_string == 0 ) {
/* If the buffer holds bad chars, don't touch it... */
XtAppWarningMsg( app_con,
"convertError", "multiSource", "XawError",
XtName( XtParent( (Widget) src ) ), NULL, NULL);
return( FALSE );
}
/* assert: mb_string holds good characters so the buffer is fine */
if (src->multi_src.allocated_string == TRUE)
XtFree(src->multi_src.string);
else
src->multi_src.allocated_string = TRUE;
src->multi_src.string = mb_string;
}
src->multi_src.changes = FALSE;
return(TRUE);
}
/* Function Name: XawMultiSaveAsFile
* Description: Save the current buffer as a file.
* Arguments: w - the MultiSrc widget.
* name - name of the file to save this file into.
* Returns: True if the save was sucessful.
*
* The public interface is XawAsciiSaveAsFile!
*/
Boolean
#if NeedFunctionPrototypes
_XawMultiSaveAsFile(
Widget w,
_Xconst char* name)
#else
_XawMultiSaveAsFile(w, name)
Widget w;
String name;
#endif
{
MultiSrcObject src = (MultiSrcObject) w;
String mb_string;
Boolean ret;
mb_string = StorePiecesInString( src );
if ( mb_string != 0 ) {
ret = WriteToFile( mb_string, name );
XtFree( mb_string );
return( ret );
}
/* otherwise there was a conversion error. So print widget name too. */
XtAppWarningMsg( XtWidgetToApplicationContext(w),
"convertError", "multiSource", "XawError",
XtName( XtParent( (Widget) src ) ), NULL, NULL);
return( False );
}
/************************************************************
*
* Private Functions.
*
************************************************************/
static void
RemoveOldStringOrFile(src, checkString)
MultiSrcObject src;
Boolean checkString;
{
FreeAllPieces(src);
if (checkString && src->multi_src.allocated_string) {
XtFree(src->multi_src.string);
src->multi_src.allocated_string = False;
src->multi_src.string = NULL;
}
}
/* Function Name: WriteToFile
* Description: Write the string specified to the begining of the file
* specified.
* Arguments: string - string to write.
* name - the name of the file
* Returns: returns TRUE if sucessful, FALSE otherwise.
*/
static Boolean
WriteToFile(string, name)
String string, name;
{
int fd;
if ( ((fd = creat(name, 0666)) == -1 ) ||
(write(fd, string, sizeof(unsigned char) * strlen(string)) == -1) )
return(FALSE);
if ( close(fd) == -1 )
return(FALSE);
return(TRUE);
}
/* Function Name: StorePiecesInString
* Description: store the pieces in memory into a char string.
* Arguments: src - the multiSrc to gather data from
* Returns: char *mb_string. Caller must free.
* or 0: conversion error. Caller must panic!
*/
static String
StorePiecesInString(src)
MultiSrcObject src;
{
wchar_t* wc_string;
char *mb_string;
int char_count = src->multi_src.length;
XawTextPosition first;
MultiPiece * piece;
/* I believe the char_count + 1 and the NULL termination are unneeded! FS*/
wc_string = (wchar_t*) XtMalloc((unsigned)(char_count + 1) * sizeof(wchar_t));
for (first = 0, piece = src->multi_src.first_piece ; piece != NULL;
first += piece->used, piece = piece->next)
(void) wcsncpy( wc_string + first, piece->text, piece->used );
wc_string[ char_count ] = (wchar_t)0; /* NULL terminate this sucker. */
/* This will refill all pieces to capacity. */
if ( src->multi_src.data_compression ) {
FreeAllPieces( src );
LoadPieces( src, NULL, (char *)wc_string );
}
/* Lastly, convert it to a MB format and send it back. */
mb_string = _XawTextWCToMB( XtDisplayOfObject( (Widget)src ),
wc_string, &char_count );
/* NOTE THAT mb_string MAY BE ZERO IF THE CONVERSION FAILED. */
XtFree( (char*) wc_string );
return( mb_string );
}
/* Function Name: InitStringOrFile.
* Description: Initializes the string or file.
* Arguments: src - the MultiSource.
* Returns: none - May exit though.
*/
static FILE *
InitStringOrFile(src, newString)
MultiSrcObject src;
Boolean newString;
{
char * open_mode = NULL;
FILE * file;
char fileName[TMPSIZ];
Display *d = XtDisplayOfObject((Widget)src);
if (src->multi_src.type == XawAsciiString) {
if (src->multi_src.string == NULL)
src->multi_src.length = 0;
else if (! src->multi_src.use_string_in_place) {
int length;
String temp = XtNewString(src->multi_src.string);
if ( src->multi_src.allocated_string )
XtFree( src->multi_src.string );
src->multi_src.allocated_string = True;
src->multi_src.string = temp;
length = strlen(src->multi_src.string);
/* Wasteful, throwing away the WC string, but need side effect! */
(void) _XawTextMBToWC(d, src->multi_src.string, &length);
src->multi_src.length = (XawTextPosition) length;
} else {
src->multi_src.length = strlen(src->multi_src.string);
/* In case the length resource is incorrectly set */
if (src->multi_src.length > src->multi_src.multi_length)
src->multi_src.multi_length = src->multi_src.length;
if (src->multi_src.multi_length == MAGIC_VALUE)
src->multi_src.piece_size = src->multi_src.length;
else
src->multi_src.piece_size = src->multi_src.multi_length + 1;
}
/*((TextWidget)src->object.parent)->text.lastPos = src->multi_src.length;*/
return(NULL);
}
/*
* type is XawAsciiFile.
*/
src->multi_src.is_tempfile = FALSE;
switch (src->text_src.edit_mode) {
case XawtextRead:
if (src->multi_src.string == NULL)
XtErrorMsg("NoFile", "multiSourceCreate", "XawError",
"Creating a read only disk widget and no file specified.",
NULL, 0);
open_mode = "r";
break;
case XawtextAppend:
case XawtextEdit:
if (src->multi_src.string == NULL) {
if ( src->multi_src.allocated_string )
XtFree( src->multi_src.string );
src->multi_src.allocated_string = False;
src->multi_src.string = fileName;
(void) tmpnam(src->multi_src.string);
src->multi_src.is_tempfile = TRUE;
open_mode = "w";
} else
open_mode = "r+";
break;
default:
XtErrorMsg("badMode", "multiSourceCreate", "XawError",
"Bad editMode for multi source; must be Read, Append or Edit.",
NULL, NULL);
}
/* Allocate new memory for the temp filename, because it is held in
* a stack memory buffer. We must verify that all routines that set
* .string first check .allocated_string and free it - plumbing Sheeran.
*/
if (newString || src->multi_src.is_tempfile) {
if ( src->multi_src.allocated_string )
src->multi_src.string = XtNewString(src->multi_src.string);
src->multi_src.allocated_string = TRUE;
}
if (!src->multi_src.is_tempfile) {
if ((file = fopen(src->multi_src.string, open_mode)) != 0) {
(void) fseek(file, (Off_t)0, 2);
src->multi_src.length = ftell (file);
return file;
} else {
String params[2];
Cardinal num_params = 2;
params[0] = src->multi_src.string;
params[1] = strerror(errno);
XtAppWarningMsg(XtWidgetToApplicationContext((Widget)src),
"openError", "multiSourceCreate", "XawWarning",
"Cannot open file %s; %s", params, &num_params);
}
}
src->multi_src.length = 0;
return((FILE *)NULL);
#undef StrLen
}
/* LoadPieces: This routine takes either the MB contents of open file `file' or the
MB contents of string or the MB contents of src->multi_src.string and places
them in Pieces in WC format.
CAUTION: You must have src->multi_src.length set to file length bytes
when src->multi_src.type == XawAsciiFile. src->multi_src.length must be
the length of the parameter string if string is non-NULL. */
static void
LoadPieces(src, file, string)
MultiSrcObject src;
FILE* file;
char* string;
{
Display *d = XtDisplayOfObject((Widget)src);
wchar_t* local_str, *ptr;
MultiPiece* piece = NULL;
XawTextPosition left;
int bytes = sizeof(wchar_t);
char* temp_mb_holder = NULL;
/*
* This is tricky - the _XawTextMBtoWC converter uses its 3rd arg
* in as MB length, out as WC length. We want local_length to be
* WC count.
*/
int local_length = src->multi_src.length;
if (string != NULL) {
/*
* ASSERT: IF our caller passed a non-null string, THEN
* src->multi_src.length is currently string's * byte count,
* AND string is in a MB format.
*/
local_str = _XawTextMBToWC(d, (char *)string, &local_length);
src->multi_src.length = (XawTextPosition) local_length;
} else if (src->multi_src.type != XawAsciiFile) {
/*
* here, we are not changing the contents, just reloading,
* so don't change len...
*/
local_length = src->multi_src.string ?
strlen( src->multi_src.string ) : 0;
local_str = _XawTextMBToWC( d, (char*)src->multi_src.string, &local_length );
} else {
if (src->multi_src.length != 0) {
temp_mb_holder =
XtMalloc((unsigned)(src->multi_src.length + 1) * sizeof(unsigned char));
fseek(file, (Off_t)0, 0);
src->multi_src.length = fread (temp_mb_holder,
(Size_t)sizeof(unsigned char),
(Size_t)src->multi_src.length, file);
if (src->multi_src.length <= 0)
XtAppErrorMsg( XtWidgetToApplicationContext ((Widget) src),
"readError", "multiSource", "XawError",
"fread returned error.", NULL, NULL);
local_length = src->multi_src.length;
local_str = _XawTextMBToWC(d, temp_mb_holder, &local_length);
src->multi_src.length = local_length;
if ( local_str == 0 ) {
String params[2];
Cardinal num_params;
static char err_text[] =
"<<< FILE CONTENTS NOT REPRESENTABLE IN THIS LOCALE >>>";
params[0] = XtName(XtParent((Widget)src));
params[1] = src->multi_src.string;
num_params = 2;
XtAppWarningMsg( XtWidgetToApplicationContext((Widget)src),
"readLocaleError", "multiSource", "XawError",
"%s: The file `%s' contains characters not representable in this locale.",
params, &num_params);
src->multi_src.length = sizeof err_text;
local_length = src->multi_src.length;
local_str = _XawTextMBToWC(d, err_text, &local_length);
src->multi_src.length = local_length;
}
} else { /*ASSERT that since following while loop looks at local_length
this isn't needed. Sheeran, Omron KK, 1993/07/15
temp_mb_holder[src->multi_src.length] = '\0';*/
local_str = (wchar_t*)temp_mb_holder;
}
}
if (src->multi_src.use_string_in_place) {
piece = AllocNewPiece(src, piece);
piece->used = Min(src->multi_src.length, src->multi_src.piece_size);
piece->text = (wchar_t*)src->multi_src.string;
return;
}
ptr = local_str;
left = local_length;
do {
piece = AllocNewPiece(src, piece);
piece->text = (wchar_t*)XtMalloc(src->multi_src.piece_size * bytes);
piece->used = Min(left, src->multi_src.piece_size);
if (piece->used != 0)
(void) wcsncpy(piece->text, ptr, piece->used);
left -= piece->used;
ptr += piece->used;
} while (left > 0);
if ( temp_mb_holder )
XtFree( (char*) temp_mb_holder );
}
/* Function Name: AllocNewPiece
* Description: Allocates a new piece of memory.
* Arguments: src - The MultiSrc Widget.
* prev - the piece just before this one, or NULL.
* Returns: the allocated piece.
*/
static MultiPiece *
AllocNewPiece(src, prev)
MultiSrcObject src;
MultiPiece * prev;
{
MultiPiece * piece = XtNew(MultiPiece);
if (prev == NULL) {
src->multi_src.first_piece = piece;
piece->next = NULL;
}
else {
if (prev->next != NULL)
(prev->next)->prev = piece;
piece->next = prev->next;
prev->next = piece;
}
piece->prev = prev;
return(piece);
}
/* Function Name: FreeAllPieces
* Description: Frees all the pieces
* Arguments: src - The MultiSrc Widget.
* Returns: none.
*/
static void
FreeAllPieces(src)
MultiSrcObject src;
{
MultiPiece * next, * first = src->multi_src.first_piece;
if (first->prev != NULL)
printf("Xaw MultiSrc Object: possible memory leak in FreeAllPieces().\n");
for ( ; first != NULL ; first = next ) {
next = first->next;
RemovePiece(src, first);
}
}
/* Function Name: RemovePiece
* Description: Removes a piece from the list.
* Arguments:
* piece - the piece to remove.
* Returns: none.
*/
static void
RemovePiece(src, piece)
MultiSrcObject src;
MultiPiece* piece;
{
if (piece->prev == NULL)
src->multi_src.first_piece = piece->next;
else
(piece->prev)->next = piece->next;
if (piece->next != NULL)
(piece->next)->prev = piece->prev;
if (!src->multi_src.use_string_in_place)
XtFree((char *)piece->text);
XtFree((char *)piece);
}
/* Function Name: FindPiece
* Description: Finds the piece containing the position indicated.
* Arguments: src - The MultiSrc Widget.
* position - the position that we are searching for.
* RETURNED first - the position of the first character in this piece.
* Returns: piece - the piece that contains this position.
*/
static MultiPiece *
FindPiece(src, position, first)
MultiSrcObject src;
XawTextPosition position, *first;
{
MultiPiece * old_piece = NULL, * piece = src->multi_src.first_piece;
XawTextPosition temp;
for ( temp = 0 ; piece != NULL ; temp += piece->used, piece = piece->next ) {
*first = temp;
old_piece = piece;
if ((temp + piece->used) > position)
return(piece);
}
return(old_piece); /* if we run off the end the return the last piece */
}
/* Function Name: BreakPiece
* Description: Breaks a full piece into two new pieces.
* Arguments: src - The MultiSrc Widget.
* piece - the piece to break.
* Returns: none.
*/
#define HALF_PIECE (src->multi_src.piece_size/2)
static void
BreakPiece(src, piece)
MultiSrcObject src;
MultiPiece* piece;
{
MultiPiece * new = AllocNewPiece(src, piece);
new->text = (wchar_t*)XtMalloc(src->multi_src.piece_size * sizeof(wchar_t));
(void) wcsncpy(new->text, piece->text + HALF_PIECE,
src->multi_src.piece_size - HALF_PIECE);
piece->used = HALF_PIECE;
new->used = src->multi_src.piece_size - HALF_PIECE;
}
/* Convert string "XawAsciiString" and "XawAsciiFile" to quarks. */
/* ARGSUSED */
static void
CvtStringToMultiType(args, num_args, fromVal, toVal)
XrmValuePtr args; /* unused */
Cardinal* num_args; /* unused */
XrmValuePtr fromVal;
XrmValuePtr toVal;
{
static XawAsciiType type;
static XrmQuark XtQEstring = NULLQUARK;
static XrmQuark XtQEfile;
XrmQuark q;
char lowerName[BUFSIZ];
if (XtQEstring == NULLQUARK) {
XtQEstring = XrmPermStringToQuark(XtEstring);
XtQEfile = XrmPermStringToQuark(XtEfile);
}
if (strlen((char *) fromVal->addr) >= sizeof(lowerName)) {
XtStringConversionWarning((char *) fromVal->addr, XtRAsciiType);
return;
}
XmuCopyISOLatin1Lowered(lowerName, (char *) fromVal->addr);
q = XrmStringToQuark(lowerName);
if (q == XtQEstring) type = XawAsciiString;
if (q == XtQEfile) type = XawAsciiFile;
if (q == XtQEstring || q == XtQEfile) {
(*toVal).size = sizeof(XawAsciiType);
(*toVal).addr = (XPointer) &type;
return;
}
XtStringConversionWarning((char *) fromVal->addr, XtRAsciiType);
}
|