• R/O
  • SSH

wp2latex: Commit

WP2LaTeX sources.


Commit MetaInfo

Revision8172f04b8a70707e41b1e45442ff4433e8c877c8 (tree)
Zeit2022-06-01 08:05:02
AutorFojtik
CommiterFojtik

Log Message

Update "struct" component of atoms library.

Ändern Zusammenfassung

Diff

diff -r 49350998eaae -r 8172f04b8a70 trunk/sources.cc/atoms/include/struct.h
--- a/trunk/sources.cc/atoms/include/struct.h Sun May 29 12:23:25 2022 +0200
+++ b/trunk/sources.cc/atoms/include/struct.h Wed Jun 01 01:05:02 2022 +0200
@@ -1,8 +1,8 @@
11 /**************************************************
2-* unit: struct release 0.12 *
2+* unit: struct release 0.13 *
33 * STRUCT.H - Provides some big and little endian abstraction functions,
44 * for manipulating with structures.
5-* Copyright (C) 1999-2020 Jaroslav Fojtik
5+* Copyright (C) 1999-2022 Jaroslav Fojtik
66 **************************************************/
77 #ifndef _STRUCT_H_
88 #define _STRUCT_H_
@@ -13,7 +13,7 @@
1313 /*
1414 #undef LO_ENDIAN //Signalise that system is native LowEndian
1515 #define HI_ENDIAN //Signalise that system is native HighEndian
16-#define EXPAND_OPS //hack to speed up
16+#define EXPAND_OPS //hack to speed up; please note that EXPAND_OPS does not work on AMD64; works on x86.
1717 */
1818
1919 #if defined(LO_ENDIAN) && defined(HI_ENDIAN)
@@ -26,15 +26,17 @@
2626 #endif
2727 /* functions from struct.c */
2828
29+
2930 #ifdef EXPAND_OPS
3031 #ifdef LO_ENDIAN
31- #define RdWORD_LoEnd(pnum,f) fread((pnum),1,2,f)
32- #define RdDWORD_LoEnd(pnum,f) fread((pnum),1,4,f)
33- #define RdQWORD_LoEnd(pnum,f) fread((pnum),1,8,f)
34- #define WrWORD_LoEnd(num,f) fwrite((&num),1,2,f)
35- #define WrDWORD_LoEnd(num,f) fwrite((&num),1,4,f)
36- #define WrQWORD_LoEnd(num,f) fwrite((&num),1,8,f)
37- #define RdFLOAT_LoEnd(num,f) fread((pnum),1,4,f)
32+ #define RdWORD_LoEnd(pnum,f) fread(pnum,1,2,f)
33+ #define RdDWORD_LoEnd(pnum,f) fread(pnum,1,4,f)
34+ #define RdQWORD_LoEnd(pnum,f) fread(pnum,1,8,f)
35+ #define WrWORD_LoEnd(num,f) fwrite(&num,1,2,f)
36+ #define WrDWORD_LoEnd(num,f) fwrite(&num,1,4,f)
37+ #define WrQWORD_LoEnd(num,f) fwrite(&num,1,8,f)
38+ #define RdFLOAT_LoEnd(pnum,f) fread(pnum,1,4,f)
39+ #define WrFLOAT_LoEnd(num,f) fwrite(&num,1,4,f)
3840 #endif
3941 #ifdef HI_ENDIAN
4042 #define RdWORD_HiEnd(num,f) fread((num),1,2,f)
@@ -88,7 +90,19 @@
8890 #endif
8991
9092 #ifndef RdFLOAT_LoEnd
91- int RdFLOAT_LoEnd(float *flt, FILE *f);
93+ #define RdFLOAT_LoEnd(pflt,file) RdDWORD_LoEnd(((DWORD*)pflt), file)
94+#endif
95+
96+#ifndef RdFLOAT_HiEnd
97+ #define RdFLOAT_HiEnd(pflt,file) RdDWORD_HiEnd(((DWORD*)pflt), file)
98+#endif
99+
100+#ifndef WrFLOAT_LoEnd
101+ #define WrFLOAT_LoEnd(flt,file) WrDWORD_LoEnd((*(DWORD*)&flt), file)
102+#endif
103+
104+#ifndef WrFLOAT_HiEnd
105+ #define WrFLOAT_HiEnd(flt,file) WrDWORD_HiEnd((*(DWORD*)&flt), file)
92106 #endif
93107
94108 WORD fil_sreadU16(const BYTE *in);
diff -r 49350998eaae -r 8172f04b8a70 trunk/sources.cc/atoms/makefile
--- a/trunk/sources.cc/atoms/makefile Sun May 29 12:23:25 2022 +0200
+++ b/trunk/sources.cc/atoms/makefile Wed Jun 01 01:05:02 2022 +0200
@@ -24,6 +24,10 @@
2424 OBJECTS+=utf8$(OBJ)
2525 OBJECTS+=mtx_impl$(OBJ)
2626
27+
28+COMMONDEP=include/common.h $(MAKEFILE_LIST)
29+
30+
2731 #### OS autodetection part of makefile ####
2832
2933
@@ -95,16 +99,16 @@
9599 ar rcs $(TARGET_NAME) $(OBJECTS)
96100
97101
98-struct$(OBJ): struct.c
99-utf8$(OBJ): utf8.c
102+struct$(OBJ): struct.c $(COMMONDEP) include/struct.h
103+utf8$(OBJ): utf8.c $(COMMONDEP)
100104
101-%complex$(OBJ): complex.cc
102-containe$(OBJ): containe.cc
103-interval$(OBJ): interval.cc include/interval.h
104-std_str$(OBJ): std_str.cc include/std_str.h
105-stack$(OBJ): stack.cc include/stacks.h
106-sets$(OBJ): sets.cc include/sets.h
107-strings$(OBJ): strings.cc include/stringa.h
105+%complex$(OBJ): complex.cc $(COMMONDEP)
106+containe$(OBJ): containe.cc $(COMMONDEP)
107+interval$(OBJ): interval.cc $(COMMONDEP) include/interval.h
108+std_str$(OBJ): std_str.cc $(COMMONDEP) include/std_str.h
109+stack$(OBJ): stack.cc $(COMMONDEP) include/stacks.h
110+sets$(OBJ): sets.cc $(COMMONDEP) include/sets.h
111+strings$(OBJ): strings.cc $(COMMONDEP) include/stringa.h
108112
109113 all: $(TARGET_NAME)
110114 # cp -f strings/*.h include/*.h
diff -r 49350998eaae -r 8172f04b8a70 trunk/sources.cc/atoms/makefile.gen
--- a/trunk/sources.cc/atoms/makefile.gen Sun May 29 12:23:25 2022 +0200
+++ b/trunk/sources.cc/atoms/makefile.gen Wed Jun 01 01:05:02 2022 +0200
@@ -24,6 +24,10 @@
2424 OBJECTS+=utf8$(OBJ)
2525 OBJECTS+=mtx_impl$(OBJ)
2626
27+
28+COMMONDEP=include/common.h $(MAKEFILE_LIST)
29+
30+
2731 #### OS autodetection part of makefile ####
2832
2933
@@ -95,16 +99,16 @@
9599 ar rcs $(TARGET_NAME) $(OBJECTS)
96100
97101
98-struct$(OBJ): struct.c
99-utf8$(OBJ): utf8.c
102+struct$(OBJ): struct.c $(COMMONDEP) include/struct.h
103+utf8$(OBJ): utf8.c $(COMMONDEP)
100104
101-%complex$(OBJ): complex.cc
102-containe$(OBJ): containe.cc
103-interval$(OBJ): interval.cc include/interval.h
104-std_str$(OBJ): std_str.cc include/std_str.h
105-stack$(OBJ): stack.cc include/stacks.h
106-sets$(OBJ): sets.cc include/sets.h
107-strings$(OBJ): strings.cc include/stringa.h
105+%complex$(OBJ): complex.cc $(COMMONDEP)
106+containe$(OBJ): containe.cc $(COMMONDEP)
107+interval$(OBJ): interval.cc $(COMMONDEP) include/interval.h
108+std_str$(OBJ): std_str.cc $(COMMONDEP) include/std_str.h
109+stack$(OBJ): stack.cc $(COMMONDEP) include/stacks.h
110+sets$(OBJ): sets.cc $(COMMONDEP) include/sets.h
111+strings$(OBJ): strings.cc $(COMMONDEP) include/stringa.h
108112
109113 all: $(TARGET_NAME)
110114 # cp -f strings/*.h include/*.h
diff -r 49350998eaae -r 8172f04b8a70 trunk/sources.cc/atoms/makefile.in
--- a/trunk/sources.cc/atoms/makefile.in Sun May 29 12:23:25 2022 +0200
+++ b/trunk/sources.cc/atoms/makefile.in Wed Jun 01 01:05:02 2022 +0200
@@ -25,6 +25,9 @@
2525 OBJECTS+=mtx_impl$(OBJ)
2626
2727
28+COMMONDEP=include/common.h $(MAKEFILE_LIST)
29+
30+
2831 .SUFFIXES: .c .cc $(OBJ) .exe .a
2932 .PHONY: all default distclean generic clean
3033
@@ -40,16 +43,16 @@
4043 ar rcs $(TARGET_NAME) $(OBJECTS)
4144
4245
43-struct$(OBJ): struct.c
44-utf8$(OBJ): utf8.c
46+struct$(OBJ): struct.c $(COMMONDEP) include/struct.h
47+utf8$(OBJ): utf8.c $(COMMONDEP)
4548
46-%complex$(OBJ): complex.cc
47-containe$(OBJ): containe.cc
48-interval$(OBJ): interval.cc include/interval.h
49-std_str$(OBJ): std_str.cc include/std_str.h
50-stack$(OBJ): stack.cc include/stacks.h
51-sets$(OBJ): sets.cc include/sets.h
52-strings$(OBJ): strings.cc include/stringa.h
49+%complex$(OBJ): complex.cc $(COMMONDEP)
50+containe$(OBJ): containe.cc $(COMMONDEP)
51+interval$(OBJ): interval.cc $(COMMONDEP) include/interval.h
52+std_str$(OBJ): std_str.cc $(COMMONDEP) include/std_str.h
53+stack$(OBJ): stack.cc $(COMMONDEP) include/stacks.h
54+sets$(OBJ): sets.cc $(COMMONDEP) include/sets.h
55+strings$(OBJ): strings.cc $(COMMONDEP) include/stringa.h
5356
5457
5558 all: $(TARGET_NAME)
diff -r 49350998eaae -r 8172f04b8a70 trunk/sources.cc/atoms/struct.c
--- a/trunk/sources.cc/atoms/struct.c Sun May 29 12:23:25 2022 +0200
+++ b/trunk/sources.cc/atoms/struct.c Wed Jun 01 01:05:02 2022 +0200
@@ -1,9 +1,9 @@
11 /*************************************************************************
2-* unit: struct release 0.12 *
2+* unit: struct release 0.13 *
33 * struct.c - Provides some big and little endian abstraction functions,
44 * for manipulating with structures.
55 * Licency: GPL or LGPL *
6-* Copyright (C) 1999-2021 Jaroslav Fojtik
6+* Copyright (C) 1999-2022 Jaroslav Fojtik
77 **************************************************************************/
88 #include <stdio.h>
99 #include <stdarg.h>
@@ -28,6 +28,7 @@
2828 #if _MSC_VER > 1200 /* Not present in MSVC6 or less. */
2929 #include <stdlib.h>
3030 #define BYTESWAP_uint64(__pval) __pval=_byteswap_uint64(__pval)
31+ #define BYTESWAP_uint32(__pval) __pval=_byteswap_ulong(__pval)
3132 #endif
3233 #endif
3334
@@ -385,7 +386,6 @@
385386 }
386387
387388
388-
389389 int loadstruct(FILE *F,const char *description, ...)
390390 {
391391 va_list ap;
@@ -444,9 +444,9 @@
444444 int ArraySize;
445445
446446 va_start(ap, description);
447+
447448 while(*description!=0)
448449 {
449-
450450 switch(*description)
451451 {
452452 #ifndef __Ellipsis_Expand_Short
@@ -454,9 +454,9 @@
454454 case 'B':{const char c = va_arg(ap,char);
455455 writed+=fwrite(&c,1,1,F);}
456456 break;
457- case 'w':writed+=WrWORD_LoEnd( va_arg(ap,WORD),F);
457+ case 'w':writed += WrWORD_LoEnd(va_arg(ap,WORD),F);
458458 break;
459- case 'W':writed+=WrWORD_HiEnd( va_arg(ap,WORD),F);
459+ case 'W':writed+=WrWORD_HiEnd(va_arg(ap,WORD),F);
460460 break;
461461 #else //all shorts are internally converted to int
462462 case 'b':
@@ -483,9 +483,9 @@
483483
484484 writed+=fwrite(va_arg(ap,char *),1,ArraySize,F);
485485 break;
486- case 'q':writed+=WrQWORD_LoEnd( va_arg(ap,QWORD_),F);
486+ case 'q':writed+=WrQWORD_LoEnd(va_arg(ap,QWORD_),F);
487487 break;
488- case 'Q':writed+=WrQWORD_HiEnd( va_arg(ap,QWORD_),F);
488+ case 'Q':writed+=WrQWORD_HiEnd(va_arg(ap,QWORD_),F);
489489 break;
490490
491491 default:printf("Error: Unknown character %c !", *description);
@@ -497,29 +497,3 @@
497497
498498 return(writed);
499499 }
500-
501-
502-#ifndef RdFLOAT_LoEnd
503-/* Read a double word from binary file in a LowEndian Format into a current endian.
504- * parameters: FILE *f : binary input file
505- * return: DWORD *num : readed double word */
506-int RdFLOAT_LoEnd(float *pnum, FILE *f)
507-{
508-#ifdef LO_ENDIAN
509- return(fread(pnum,1,4,f));
510-#endif
511-#ifdef HI_ENDIAN
512-const int i = fread(pnum,1,4,f);
513- BYTESWAP_uint32(*pnum);
514-return i;
515-#endif
516-#if !defined(LO_ENDIAN) && !defined(HI_ENDIAN)
517-unsigned char b;
518- if(!fread( &b, 1,1,f)) return 0; *(DWORD*)pnum=(DWORD)b;
519- if(!fread( &b, 1,1,f)) return 1; *(DWORD*)pnum+=(DWORD)b * 256l;
520- if(!fread( &b, 1,1,f)) return 2; *(DWORD*)pnum+=(DWORD)b * 256l * 256l;
521- if(!fread( &b, 1,1,f)) return 3; *(DWORD*)pnum+=(DWORD)b * 256l * 256l * 256l;
522-return 4;
523-#endif
524-}
525-#endif
Show on old repository browser