Waitrud Weber’s blog

things and reminders for memories

3d: windows-make: Memorization:

*Confliction if the size changed at the same time.

  Thread1 Thread2
dummy_allocation_001

touch

|0xFFaaaaa0|

size 8

touch

|0xFFaaaaa8|

size 16

- - -
- - -
- - -

 

*

Allocation memorries should be internal in function and return it well for the call of it.

 

*

Remodification

- - - -

.\array_counter.cpp  File modified time Sat Oct 14 07:04:39 2023

...

0804 char* char_string_012 ( int num_memories ) {
0805     char* dummy_allocation_001_01 = NULL;
0806     printf("char* char_string_012 ( int num_memories ) starts. num_memories=%d dummy_allocation_001_01=%p\r\n", num_memories, dummy_allocation_001_01);
0807 // 20210731
0808 //    dummy_allocation_001_01 =NULL;
0809 //    print_memories_002();
0810     for ( int i =0; i<10; i++) {
0811         printf("character i %d/10 num_memories %d about|%p|\r\n", i, num_memories, dummy_allocation_001_01);
0812         dummy_allocation_001_01 = (char*) malloc( sizeof(char) * num_memories );
0813         printf("dummy_allocation_001_01|%p|\r\n", dummy_allocation_001_01);
0814         if ( dummy_allocation_001_01 != NULL ) {
0815             break;
0816         }
0817         a_sleep_thread ();
0818     }
0819     put_memories_002( dummy_allocation_001_01 );
0820     printf("char* char_string_012 ( int num_memories ) ends.\r\n");
0821     return dummy_allocation_001_01;
0822 }
0823 
...

0925 char* copyof_012 ( char* str ) {
0926     int ac;
0927     char* dummy_allocation_001_01 = NULL;
0928     printf("char* copyof_012 ( char* str ) starts.\r\n");
0929     ac = array_count(str);
0930     printf("array_count %d\r\n", ac );
0931     dummy_allocation_001_01 = char_string_012 ( ac + 1 );
0932     a_sleep_thread_002 ();
0933     if ( dummy_allocation_001_01 == NULL ) {
0934         printf("dummy_allocation_001_01 is null.\r\n");
0935         exit(-1);
0936     }
0937     printf("dummy_allocation_001_01 point|%p|\r\n", dummy_allocation_001_01 );
0938     put_memories( dummy_allocation_001_01 );
0939 
0940     for ( int i=0; i<ac; i++) {
0941         dummy_allocation_001_01[i] = str[i];
0942     }
0943 
0944     dummy_allocation_001_01[ac] = '\0';
0945     printf("str |%p| dummy_allocation_001_01 |%p|=|%s|\r\n", str, dummy_allocation_001_01, dummy_allocation_001_01 );
0946     printf("char* copyof_012 ( char* str ) ends.\r\n");
0947     return dummy_allocation_001_01;
0948 }

...

  - -
- - - -
- - - -
- - - -
- - - -
- - - -
- - - -

 

windows-make: csv: CSV frame ... 005

Logging is set each patch, which is actually seperated file *.c and is going to be compiled.

*

- - - - -
         
  i 14 void Initialize_firstset_004 () ends.
i 15 int file_all_size ( char* filename, int *file_end ) starts.
i 16 msg 001-filename-20230621.txt file_end |00499260| 404
i 17 int file_all_size ( char* filename, int *file_end ) ends.
i 18 int csv_once_002 (int *index, int *end_index ) starts.
i 19 SEEK index_r |0|
i 20 msg dummy |"| c|34|
i 21 count 1 word_002 |"| word_002_c |"| c|34|
i 22 SEEK index_r |1|
i 23 msg dummy |-| c|45|
i 24 count 2 word_002 |"-| word_002_c |"-| c|45|
i 25 SEEK index_r |2|
i 26 msg dummy |"| c|34|
i 27 count 3 word_002 |"-"| word_002_c |"-"| c|34|
i 28 SEEK index_r |3|
i 29 msg dummy |,| c|44|
i 30 count 4 word_002 |"-",| word_002_c |"-",| c|44|
i 31 SEEK index_r |4|
i 32 msg dummy |"| c|34|
i 33 count 5 word_002 |"-","| word_002_c |"-","| c|34|
i 34 SEEK index_r |5|
i 35 msg dummy |-| c|45|
i 36 count 6 word_002 |"-","-| word_002_c |"-","-| c|45|
i 37 SEEK index_r |6|
i 38 msg dummy |"| c|34|
i 39 count 7 word_002 |"-","-"| word_002_c |"-","-"| c|34|
i 40 SEEK index_r |7|
i 41 msg dummy |,| c|44|
i 42 count 8 word_002 |"-","-",| word_002_c |"-","-",| c|44|
i 43 SEEK index_r |8|
i 44 msg dummy |"| c|34|
i 45 count 9 word_002 |"-","-","| word_002_c |"-","-","| c|34|
i 46 SEEK index_r |9|
i 47 msg dummy |-| c|45|
i 48 count 10 word_002 |"-","-","-| word_002_c |"-","-","-| c|45|
i 49 int csv_once_002 (int *index, int *end_index ) ends.
i 50 print_log :
LOG_001* Logging::print_log () ends.
     
  And, there is a remaining quote part of solution in csv.      
 

i 30 int csv_once_002 (int *index, int *end_index ) starts.
i 31 SEEK index_r |0|
i 32 msg dummy |"| c|34|
i 33 count 1 word_002 |"| word_002_c |"| c|34|
i 34 SEEK index_r |1|
i 35 msg dummy |-| c|45|
i 36 count 2 word_002 |"-| word_002_c |"-| c|45|
i 37 SEEK index_r |2|
i 38 msg dummy |"| c|34|
i 39 count 3 word_002 |"-"| word_002_c |"-"| c|34|
i 40 SEEK index_r |3|
i 41 int puttheword_004 ( int ii, int jj, char* word ) starts.
i 42 msg 1 0 grid matrix g
i 43 msg 1 0 word "-"
i 44 int puttheword_004 ( int ii, int jj, char* word ) end.
i 45 SEEK index_r |4|
i 46 msg dummy |"| c|34|
i 47 count 5 word_002 |"| word_002_c |"| c|34|
i 48 SEEK index_r |5|
i 49 msg dummy |-| c|45|
i 50 count 6 word_002 |"-| word_002_c |"-| c|45|
i 51 SEEK index_r |6|
i 52 msg dummy |"| c|34|
i 53 count 7 word_002 |"-"| word_002_c |"-"| c|34|
i 54 SEEK index_r |7|
i 55 int puttheword_004 ( int ii, int jj, char* word ) starts.
i 56 msg 2 0 grid matrix g
i 57 msg 2 0 word "-"
i 58 int puttheword_004 ( int ii, int jj, char* word ) end.
i 59 SEEK index_r |8|
i 60 msg dummy |"| c|34|
i 61 count 9 word_002 |"| word_002_c |"| c|34|
i 62 SEEK index_r |9|
i 63 msg dummy |-| c|45|
i 64 count 10 word_002 |"-| word_002_c |"-| c|45|
i 65 int csv_once_002 (int *index, int *end_index ) ends.
i 66 print_log :
LOG_001* Logging::print_log () ends.

     

windows-make: csv: CSV frame ... 004

Memory allocation is like the Matrix like Lotus and Excel.
Function realloc and malloc work well, which is a beautiful work in C language.

*

- - - - -
 

read_csv_004.cpp  File modified time Sun Aug 06 22:32:51 2023

0001 #include <tchar.h>
0002 #include <windows.h>
0003 #include <windowsx.h>
0004 
0005 #include <ctime>
0006 
0007 #include <stdio.h>
0008 #include <stdlib.h>
0009 
0010 #include "Print.h"
0011 #include "array_counter.h"
0012 #include "parse.h"
0013 
0014 #include "read_csv_004.h"
0015 
0016 GRID_MATRIX_004* grid_matrix_004 = NULL;
0017 
0018 int puttheword_004 ( int ii, int jj, char* word ) ;
0019 int    initialize_grid_matrix_004 () ;
0020 
0021 //
0022 int puttheword_004 ( int ii, int jj, char* word ) {
0023     int a, i, rmode, ri;
0024 
0025     if ( grid_matrix_004 == NULL ) {
0026         a = initialize_grid_matrix_004 ();
0027     }
0028 
0029     rmode = 0;
0030     if (grid_matrix_004->width_index_num_max <= ii ) {
0031         rmode = 1;
0032         ri = grid_matrix_004->width_index_num_max;
0033         for ( i= 0; ii < grid_matrix_004->width_index_num_max; i++ ) {
0034             grid_matrix_004->width_index_num_max *= 2;
0035         }
0036         grid_matrix_004->grid_matrix = (char***)realloc ( grid_matrix_004->grid_matrix , sizeof(char**) * grid_matrix_004->width_index_num_max );
0037         for ( i = ri; i< grid_matrix_004->height_index_num_max; i++ ) {
0038             grid_matrix_004->grid_matrix[i] = (char**)realloc ( grid_matrix_004->grid_matrix[i], sizeof(char*) * grid_matrix_004->height_index_num_max );
0039         }
0040     }
0041 
0042     if (grid_matrix_004->height_index_num_max <jj ) {
0043         rmode = 2;
0044         for ( i= 0; jj < grid_matrix_004->height_index_num_max; i++ ) {
0045             grid_matrix_004->height_index_num_max *= 2;
0046         }
0047         for ( i = 0; i< grid_matrix_004->height_index_num_max; i++ ) {
0048             grid_matrix_004->grid_matrix[i] = (char**)realloc ( grid_matrix_004->grid_matrix[i], sizeof(char*) * grid_matrix_004->height_index_num_max );
0049         }
0050     }
0051 
0052     aFree(grid_matrix_004->grid_matrix[ii][jj]);
0053     grid_matrix_004->grid_matrix[ii][jj] = (char*) copyof ( word );
0054 
0055     return 0;
0056 }
0057 
0058 
0059 //
0060 int    initialize_grid_matrix_004 () {
0061     int i, j;
0062 
0063     grid_matrix_004 = (GRID_MATRIX_004*) malloc ( sizeof (GRID_MATRIX_004) );
0064     if ( grid_matrix_004 == NULL ) {
0065         exit(-1);
0066     }
0067 
0068     grid_matrix_004->grid_matrix = (char***)malloc ( sizeof(char**) * grid_matrix_004->width_index_num_max );
0069     for ( i = 0; i< grid_matrix_004->width_index_num_max; i++ ) {
0070         grid_matrix_004->grid_matrix[i] = (char**)malloc ( sizeof(char*) * grid_matrix_004->height_index_num_max );
0071         if ( grid_matrix_004->grid_matrix[i] == NULL ) {
0072             exit(-1);
0073         }
0074         for ( j = 0; j< grid_matrix_004->height_index_num_max; j++ ) {
0075             grid_matrix_004->grid_matrix[i][j] = (char*)copyof("g");
0076         }
0077     }
0078 
0079     return  0;
0080 }
0081 

     
 

.\read_csv_004.h  File modified time Mon Aug 07 16:48:05 2023

0001 #ifndef _SETTLE_GRID_004_H_
0002 #define _SETTLE_GRID_004_H_
0003 
0004 typedef struct grid_matrix_struct_004 {
0005     int width_index = 0;
0006     int width_index_num = 0;
0007     int width_index_num_max = 8;
0008     int height_index = 0;
0009     int height_index_num = 0;
0010     int height_index_num_max = 8;
0011     char***    grid_matrix = NULL;
0012 } GRID_MATRIX_004;
0013 
0014 extern int puttheword_004 ( int ii, int jj, char* word ) ;
0015 extern int filesize_004( FILE *fp ) ;
0016 extern int file_all_size ( char* filename, int *file_end ) ;
0017 extern int Set_Logging_read_csv_004 ( Logging* log ) ;
0018 
0019 #endif
0020 

     
 

Frrst arrays should be set as initialization and 8 and 8 in 2 demention but it was not settled, and so, the execution was failed and modified. Allocation is sized only and doesn't ensure any set of intialization with malloc.

 

.\read_csv_004.cpp  File modified time Mon Aug 07 17:44:03 2023

0001 #include <tchar.h>
0002 #include <windows.h>
0003 #include <windowsx.h>
0004 
0005 #include <ctime>
0006 
0007 #include <stdio.h>
0008 #include <stdlib.h>
0009 
0010 #include "Print.h"
0011 #include "array_counter.h"
0012 #include "parse.h"
0013 
0014 #include "log_001.h"
0015 
0016 #include "read_csv_004.h"
0017 
0018 GRID_MATRIX_004* grid_matrix_004 = NULL;
0019 
0020 static Logging* log_001;
0021 static LOG_001* dlog_001 = NULL;
0022 
...
0082 //
0083 int    initialize_grid_matrix_004 () {
0084     int i, j;
0085     char msg[255];
0086 
0087     dlog_001 = log_001->update_log ( (char*)"int    initialize_grid_matrix_004 () starts." );
0088 
0089     grid_matrix_004 = (GRID_MATRIX_004*) malloc ( sizeof (GRID_MATRIX_004) );
0090     if ( grid_matrix_004 == NULL ) {
0091         exit(-1);
0092     }
0093 
0094     grid_matrix_004->width_index_num_max = 8;
0095     grid_matrix_004->height_index_num_max = 8;
0096 
0097     grid_matrix_004->grid_matrix = (char***)malloc ( sizeof(char**) * grid_matrix_004->width_index_num_max );
0098 
0099     sprintf( msg, "grid_matrix_004->grid_matrix |%p| grid_matrix_004->width_index_num_max=%d", grid_matrix_004->grid_matrix, grid_matrix_004->width_index_num_max );
0100     dlog_001 = log_001->update_log ( (char*) msg );
0101 
0102     sprintf( msg, "grid_matrix_004->grid_matrix |%p| grid_matrix_004->height_index_num_max=%d", grid_matrix_004->grid_matrix, grid_matrix_004->height_index_num_max );
0103     dlog_001 = log_001->update_log ( (char*) msg );
0104 
0105     for ( i = 0; i< grid_matrix_004->width_index_num_max; i++ ) {
0106         grid_matrix_004->grid_matrix[i] = (char**)malloc ( sizeof(char*) * grid_matrix_004->height_index_num_max );
0107         if ( grid_matrix_004->grid_matrix[i] == NULL ) {
0108             exit(-1);
0109         }
0110         for ( j = 0; j< grid_matrix_004->height_index_num_max; j++ ) {
0111             grid_matrix_004->grid_matrix[i][j] = (char*)copyof("g");
0112         }
0113     }
0114 
0115     dlog_001 = log_001->update_log ( (char*)"int    initialize_grid_matrix_004 () ends." );
0116     return  0;
0117 }
0118 
0119 
0120 //
0121 int file_all_size ( char* filename, int *file_end ) {
0122     FILE *fp;
0123     char msg[255];
0124 
0125     dlog_001 = log_001->update_log ( (char*)"int file_all_size ( char* filename, int *file_end ) starts." );
0126 
0127     fp = fopen ( filename, "rb" );
0128     *file_end = filesize_004 ( fp );
0129 
0130     fclose(fp);
0131 
0132     sprintf( msg, "msg %s file_end |%p| %d", filename, file_end, *file_end );
0133 
0134     dlog_001 = log_001->update_log ( (char*) msg );
0135 
0136     dlog_001 = log_001->update_log ( (char*)"int file_all_size ( char* filename, int *file_end ) ends." );
0137 }
0138 
0139 //
0140 int filesize_004( FILE *fp ) {
0141 
0142     fseek(fp, 0L, SEEK_END);
0143     int sz = ftell(fp);
0144 
0145     fseek(fp, 0L, SEEK_SET);
0146 
0147     return sz;
0148 }
0149 
0150 //
0151 int Set_Logging_read_csv_004 ( Logging* log ) {
0152     log_001 = (Logging*)log;
0153     return 0;
0154 }
0155 
0156 
0157 

     
 

i 9 void Initialize_firstset_004 () starts.
i 10 1
i 11 2
i 12 3
i 13 4
i 14 void Initialize_firstset_004 () ends.
i 15 int file_all_size ( char* filename, int *file_end ) starts.
i 16 msg 001-filename-20230621.txt file_end |00499260| 404
i 17 int file_all_size ( char* filename, int *file_end ) ends.
i 18 int puttheword_004 ( int ii, int jj, char* word ) starts.
i 19 int    initialize_grid_matrix_004 () starts.
i 20 grid_matrix_004->grid_matrix |025406A8| grid_matrix_004->width_index_num_max=8
i 21 grid_matrix_004->grid_matrix |025406A8| grid_matrix_004->height_index_num_max=8
i 22 int    initialize_grid_matrix_004 () ends.
i 23 msg 1 1 grid matrix g

i 24 msg 1 1 word aaa

i 25 int puttheword_004 ( int ii, int jj, char* word ) end.
i 26 print_log :
LOG_001* Logging::print_log () ends.

     
  .\read_csv_004.cpp  File modified time Wed Aug 09 17:09:54 2023
...
0032 int puttheword_004 ( int ii, int jj, char* word ) {
0033     int a, i, rmode, ri;
0034     char msg[255];
0035 
0036     dlog_001 = log_001->update_log ( (char*)"int puttheword_004 ( int ii, int jj, char* word ) starts." );
0037 
0038     if ( grid_matrix_004 == NULL ) {
0039         a = initialize_grid_matrix_004 ();
0040     }
0041 
0042     rmode = 0;
0043     if (grid_matrix_004->width_index_num_max <= ii ) {
0044         rmode = 1;
0045         ri = grid_matrix_004->width_index_num_max;
0046         for ( i= 0; ii >= grid_matrix_004->width_index_num_max; i++ ) {
0047             grid_matrix_004->width_index_num_max *= 2;
0048         }
0049         printf("out i %d jj %d width_index_num_max %d\r\n", i, jj, grid_matrix_004->width_index_num_max );
0050         grid_matrix_004->grid_matrix = (char***)realloc ( grid_matrix_004->grid_matrix , sizeof(char**) * grid_matrix_004->width_index_num_max );
0051         for ( i = ri; i< grid_matrix_004->height_index_num_max; i++ ) {
0052             grid_matrix_004->grid_matrix[i] = (char**)realloc ( grid_matrix_004->grid_matrix[i], sizeof(char*) * grid_matrix_004->height_index_num_max );
0053         }
0054     }
0055 
0056     if (grid_matrix_004->height_index_num_max <=jj ) {
0057         rmode = 2;
0058         printf("in i %d jj %d height_index_num_max %d\r\n", i, jj, grid_matrix_004->height_index_num_max );
0059         for ( i= 0; jj >= grid_matrix_004->height_index_num_max; i++ ) {
0060             printf("i %d jj %d height_index_num_max %d\r\n", i, jj, grid_matrix_004->height_index_num_max );
0061             grid_matrix_004->height_index_num_max *= 2;
0062         }
0063         printf("out i %d jj %d height_index_num_max %d\r\n", i, jj, grid_matrix_004->height_index_num_max );
0064         for ( i = 0; i< grid_matrix_004->height_index_num_max; i++ ) {
0065             grid_matrix_004->grid_matrix[i] = (char**)realloc ( grid_matrix_004->grid_matrix[i], sizeof(char*) * grid_matrix_004->height_index_num_max );
0066         }
0067     }
0068 
0069     sprintf( msg, "msg %d %d grid matrix %s", ii, jj, (char*) grid_matrix_004->grid_matrix[ii][jj]  );
0070     dlog_001 = log_001->update_log ( (char*) msg );
0071 
0072     aFree(grid_matrix_004->grid_matrix[ii][jj]);
0073     grid_matrix_004->grid_matrix[ii][jj] = (char*) copyof ( word );
0074 
0075 
0076     sprintf( msg, "msg %d %d word %s", ii, jj, word  );
0077     dlog_001 = log_001->update_log ( (char*) msg );
0078 
0079     dlog_001 = log_001->update_log ( (char*)"int puttheword_004 ( int ii, int jj, char* word ) end." );
0080 
0081     return 0;
0082 }
     
  i 14  ii, int jj, char* word ) end.
i 15 int file_all_size ( char* filename, int *file_end ) starts.
i 16 msg 001-filename-20230621.txt file_end |0049A260| 404
i 17 int file_all_size ( char* filename, int *file_end ) ends.
i 18 int puttheword_004 ( int ii, int jj, char* word ) starts.
i 19 int    initialize_grid_matrix_004 () starts.
i 20 grid_matrix_004->grid_matrix |0099CDC8| grid_matrix_004->width_index_num_max=8
i 21 grid_matrix_004->grid_matrix |0099CDC8| grid_matrix_004->height_index_num_max=8
i 22 int    initialize_grid_matrix_004 () ends.
i 23 msg 1 1 grid matrix g
i 24 msg 1 1 word aaa
i 25 int puttheword_004 ( int ii, int jj, char* word ) end.
i 26 int puttheword_004 ( int ii, int jj, char* word ) starts.
i 27 msg 8 8 grid matrix (null)
i 28 msg 8 8 word bbb
i 29 int puttheword_004 ( int ii, int jj, char* word ) end.
     
         
         


*

windows-make: csv: CSV frame ... 003

Patch of object is read_csv_003.o in C, which is going to be attached and its compilation is once.

-   - - -
 

.\read_csv_003.cpp  File modified time Sun Aug 06 18:09:44 2023

0001 #include <tchar.h>
0002 #include <windows.h>
0003 #include <windowsx.h>
0004 
0005 #include <ctime>
0006 
0007 #include <stdio.h>
0008 #include <stdlib.h>
0009 
0010 #include "Print.h"
0011 #include "array_counter.h"
0012 #include "parse.h"
0013 
0014 #include "read_csv_003.h"
0015 
0016 int endline_003 ( char bc, char c) ;
0017 
0018 int endline_003 ( char bc, char c) {
0019     if ( bc == '\r' && c == '\n' ) return 1;
0020     return 0;
0021 }
0022 
0023 

     
         
         
         

*

windows-make: csv: CSV frame ... 002

Setting a file name and which seek is well for the analyzation.
And, csv analyzation is commented out of function "put the word".

 

*

-   - - -
 

read_csv_002.h  File modified time Mon Aug 07 16:48:43 2023

0001 #ifndef _SETTLE_GRID_002_H_
0002 #define _SETTLE_GRID_002_H_
0003 
0004 extern int csv_once_002 (int *index, int *end_index ) ;
0005 extern char* m_concat_c_002 ( char* word_002 , int c ) ;
0006 extern int Set_Logging_read_csv_002 ( Logging* log ) ;
0007 extern int Set_Filename_002 ( char* filename ) ;
0008 
0009 #endif
0010 

     
 

read_csv_002.cpp  File modified time Mon Aug 07 16:48:49 2023

0001 #include <tchar.h>
0002 #include <windows.h>
0003 #include <windowsx.h>
0004 
0005 #include <ctime>
0006 
0007 #include <stdio.h>
0008 #include <stdlib.h>
0009 
0010 #include "Print.h"
0011 #include "array_counter.h"
0012 #include "parse.h"
0013 
0014 #include "log_001.h"
0015 
0016 #include "read_csv_002.h"
0017 #include "read_csv_003.h"
0018 #include "read_csv_004.h"
0019 
0020 static Logging* log_001;
0021 static LOG_001* dlog_001 = NULL;
0022 
0023 static char* filename_002 = NULL;
0024 static FILE* rfp = NULL;
0025 
0026 int csv_once (int *index, int *end_index ) ;
0027 char get_char_002 (int *index) ;
0028 int endline_002 ( char bc, char c) ;
0029 int puttheword_002 ( int ii, int jj, char* word_002 ) ;
0030 char* m_concat_c_002 ( char* word_002 , int c ) ;
0031 int Set_Logging_read_csv_002 ( Logging* log ) ;
0032 
0033 
0034 char* word_002  = NULL;
0035 char* word_002_c = NULL;
0036 
0037 // Add; mode and quotes
0038 // example
0039 int csv_once_002 (int *index, int *end_index ) {
0040     int i;
0041     int ii, jj;
0042     int mode;
0043     int count = 0;
0044     char c, bc;
0045     int word_002_cnt;
0046     int continued_flg = 0;
0047     char msg[255];
0048 
0049     dlog_001 = log_001->update_log ( (char*)"int csv_once_002 (int *index, int *end_index ) starts." );
0050 
0051     mode = 0;
0052     ii=0; jj=0;
0053 
0054     for ( i = *index; i< 10 + *index && i < *end_index; i++ ) {
0055         count++;
0056         c = get_char_002 (&i);
0057 
0058         if ( mode == 0 && c == '\,' ) {
0059             ii++;
0060 //            continued_flg = 1;
0061             continued_flg = 0;
0062         } if ( mode == 0 && endline_003 ( bc, c) ) {
0063             word_002_cnt = array_count (word_002);
0064             word_002[ word_002_cnt - 1 ] = '\0';
0065             ii++;
0066             jj++;
0067 //            continued_flg = 1;
0068             continued_flg = 0;
0069         }
0070 
0071         bc = c;
0072 
0073         if ( continued_flg == 1 ) {
0074             puttheword_004 ( ii, jj, (char*) word_002 );
0075             word_002 = NULL;
0076             continued_flg = 0;
0077             continue;
0078         }
0079 
0080 
0081         word_002_c = (char*) m_concat_c_002 ( (char*) word_002 , (int) c );
0082         aFree(word_002);
0083         word_002 = word_002_c;
0084 
0085         sprintf( msg, "count %d word_002 |%s| word_002_c |%s| c|%d|", count, word_002, word_002_c, c );
0086         dlog_001 = log_001->update_log ( (char*)msg );
0087     }
0088 
0089     *index += count;
0090     dlog_001 = log_001->update_log ( (char*)"int csv_once_002 (int *index, int *end_index ) ends." );
0091 }
0092 
0093 //
0094 char get_char_002 (int *index_r ) {
0095     char dummy[255];
0096     char rc;
0097     char msg[255];
0098 
0099     rfp = (FILE*) fopen( filename_002, "rb" );
0100     if (rfp == NULL) {
0101         exit(-1);
0102     }
0103 
0104     sprintf( msg, "SEEK index_r |%d|", *index_r );
0105     dlog_001 = log_001->update_log ( (char*)msg );
0106 
0107     fseek( rfp, *index_r, SEEK_SET);
0108     fread ( dummy, 1, 1, rfp );
0109 
0110     fclose(rfp);
0111     rc = dummy[0];
0112     return rc;
0113 }
0114 
0115 int endline_002 ( char bc, char c) {
0116     return 0;
0117 }
0118 
0119 
0120 int puttheword_002 ( int ii, int jj, char* word_002 ) {
0121     return 0;
0122 }
0123 
0124 
0125 char* m_concat_c_002 ( char* word_002 , int c ) {
0126     static char* dummy = NULL;
0127     char cc;
0128     char msg[255];
0129 
0130     cc = (char)c;
0131 
0132     if ( dummy == NULL ) {
0133         dummy = (char*) malloc ( sizeof(char) * 4 );
0134         if ( dummy == NULL ) return NULL;
0135     }
0136     dummy[0] = c;
0137     dummy[1] = '\0';
0138 
0139     sprintf( msg, "msg dummy |%s| c|%d|", dummy, c );
0140     dlog_001 = log_001->update_log ( (char*)msg );
0141 
0142     return m_concat( word_002, dummy );
0143 }
0144 
0145 //
0146 int Set_Logging_read_csv_002 ( Logging* log ) {
0147     log_001 = (Logging*)log;
0148     return 0;
0149 }
0150 
0151 int Set_Filename_002 ( char* filename ) {
0152     filename_002 = (char*)filename;
0153     return 0;
0154 }
0155 

     
         
         

windows-make: csv: CSV frame ... 001

windows-make: csv: CSV frame ... 001

In first step in csv, we created the frame.

 

001:

-   - - -
 

read_csv_001.cpp  File modified time Sat Aug 05 17:38:37 2023

0001 #include <tchar.h>
0002 #include <windows.h>
0003 #include <windowsx.h>
0004 
0005 #include <ctime>
0006 
0007 #include <stdio.h>
0008 #include <stdlib.h>
0009 
0010 #include "Print.h"
0011 #include "array_counter.h"
0012 #include "parse.h"
0013 
0014 #include "read_csv_001.h"
0015 
0016 int csv_once (int *index, int *end_index ) ;
0017 char get_char_001 () ;
0018 int endline ( char bc, char c) ;
0019 int puttheword ( int ii, int jj, char* word ) ;
0020 char* m_concat_c_001 ( char* word , int c ) ;
0021 
0022 
0023 char* word  = NULL;
0024 char* word_c = NULL;
0025 
0026 // Add; mode and quotes
0027 // example
0028 int csv_once (int *index, int *end_index ) {
0029     int i;
0030     int ii, jj;
0031     int mode;
0032     int count = 0;
0033     char c, bc;
0034     int word_cnt;
0035     int continued_flg = 0;
0036 
0037     mode = 0;
0038     ii=0; jj=0;
0039 
0040     for ( i = *index; i< 10 + *index && i < *end_index; i++ ) {
0041         count++;
0042         c = get_char_001 ();
0043 
0044         if ( mode == 0 && c == '\,' ) {
0045             ii++;
0046             continued_flg = 1;
0047         } if ( mode == 0 && endline ( bc, c) ) {
0048             word_cnt = array_count (word);
0049             word[ word_cnt - 1 ] = '\0';
0050             ii++;
0051             jj++;
0052             continued_flg = 1;
0053         }
0054 
0055         bc = c;
0056 
0057         if ( continued_flg == 1 ) {
0058             puttheword ( ii, jj, (char*) word );
0059             word = NULL;
0060             continued_flg = 0;
0061             continue;
0062         }
0063 
0064 
0065         word_c = (char*) m_concat_c_001 ( (char*) word , (int) c );
0066         aFree(word);
0067         word = word_c;
0068     }
0069 
0070     *index += count;
0071 }
0072 
0073 char get_char_001 () {
0074     return 0;
0075 }
0076 
0077 int endline ( char bc, char c) {
0078     return 0;
0079 }
0080 
0081 
0082 int puttheword ( int ii, int jj, char* word ) {
0083     return 0;
0084 }
0085 
0086 char* m_concat_c_001 ( char* word , int c ) {
0087     static char* dummy = NULL;
0088     char cc;
0089 
0090     cc = (char)c;
0091 
0092     if ( dummy == NULL ) {
0093         dummy = (char*) malloc ( sizeof(char) * 4 );
0094         if ( dummy == NULL ) return NULL;
0095     }
0096     dummy[0] = c;
0097     dummy[1] = '\0';
0098 
0099     return m_concat( word, dummy );
0100 }
0101 
0102 

     
         
         
         

002:

003:

windows-make: C++: mingw: Creation undefined numbered buffer-array.


*
For a creation of buffer as array, undefined number is failed. The below is as 6 example.*

.\settle_grid_001.h File modified time Thu Aug 03 16:16:55 2023
...
019   char** a_litteratures = NULL;
020   char* litteratures[6] = { "\"", "\,", "\{", "\}", "\ ", "\r\n" };
021
...
043 };
044
045 #endif

 

*