Waitrud Weber’s blog

things and reminders for memories

Analyzer: windows-make: error of m_replace: it can not read "$no" dollar number.

We could modify the error on the code.
There is a problem in m_replace.
And We changed it and place the simple compilation and failed it.

f:id:Waitrud_Weber:20210314172808p:plain

---

f:id:Waitrud_Weber:20210314172839p:plain

1: 

https://github.com/WaitrudWeber/source_zip/blob/master/replace_20210314-001-01.zip

2:

https://github.com/WaitrudWeber/source_zip/blob/master/replace_20210314-001-02.zip

3: 

https://github.com/WaitrudWeber/source_zip/blob/master/replace_20210314-001-03.zip

 

*about messages

The above compilation should be recognised as (char*).

And we doubt any other part especifally, the specication return (*char) in the function and try to change it, so, it might be our error and is going to be our error.

 

1 read_csv  3/14  qualified 
m_replace

3/14

3/15

not qualified

qualified 

       
       

m_replace has been already qualified.

 

* Do not doubt the memorization is error or not, just still error.

4: 

https://github.com/WaitrudWeber/source_zip/blob/master/replace_20210314-001-04.zip

m_replace works well it self.

> .\winmain_001.exe
a_001 |aaabbb
ddc|
>

main.cpp  Sun Mar 14 18:41:23 2021

  1 :#include 
  2 :#include 
  3 :#include 
  4 :
  5 :#include "Print.h"
  6 :#include "array_counter.h"
  7 :#include "parse.h"
  8 :
  9 :#include "replace.h"
 10 :
 11 :int main () {
 12 :
 13 :	char* a_001 = (char*)"aaabbb\r\nccc";
 14 :	a_001 = m_replace ( a_001, (char*)"cc", (char*)"dd" );
 15 :	printf("a_001 |%s|\r\n", a_001);
 16 :
 17 ://	int a = read_csv(".\\001-csv-20210210-001\.txt");
 18 ://	int b = replace_csv ( ".\\001-form-20210211-001\.txt");
 19 :
 20 :	return 0;
 21 :}
 22 :


We checked if the letters '<', '>' and '/' pass or not. 

 

.\main.cpp  Sun Mar 14 18:48:02 2021
...
 11 :int main () {
 12 :
 13 :	char* a_001 = (char*)"aaa<><></>bbb\r\nccc";
 14 :	a_001 = m_replace ( a_001, (char*)"cc", (char*)"dd" );
 15 :	printf("a_001 |%s|\r\n", a_001);
 16 :
 17 ://	int a = read_csv(".\\001-csv-20210210-001\.txt");
 18 ://	int b = replace_csv ( ".\\001-form-20210211-001\.txt");
 19 :
 20 :	return 0;
 21 :}
...

---

> .\winmain_001.exe
a_001 |aaa<><></>bbb
ddc|

>

 So, we limited the leter '$' is not goig to pass or not and realised is not going.
main.cpp Sun Mar 14 18:59:28 2021
... 13 : char* a_001 = (char*)"aaa<><></>$11bbb\r\nccc"; 14 : a_001 = m_replace ( a_001, (char*)"$11", (char*)"dd" ); 15 : printf("a_001 |%s|\r\n", a_001); ...

m_replace is defined like the below source code 1 in array_counter.cpp.
if we know the function well, the error doesn't happen and its fail is not for source code.
reason of falut possibilites:
1. compilation
2. work memorization
We think 1 and library and already known by hatena because they are blinded.

 ---- source code 1 start ----

.\array_counter.cpp  Sun Mar 14 17:27:06 2021
...
124 :char* m_replace ( char* char_string,
125 : char* from_string, char* to_string ) {
126 :	char c1, c2;
127 :	int count = array_count( char_string );
128 :	int a_f = array_count( from_string );
129 :	int a_t = array_count( to_string );
130 :	int a_c = 0;
131 :	char* char_string_2 = 
132 :	  (char *) malloc ( sizeof (char)*( count + a_t - 1 ) );
133 :
134 :	int cnt_replace = 0;
135 :	for ( int i = 0; i<count; i++ ) {
136 :		c1 = *( char_string + i ) ;
137 :		a_c = 0;

138 : for ( int j=0; j<a_f && j <count; j++ ) {

138 : for ( int j=0; j<a_f && j <count; j++ ) {

139 : c2 = *( from_string + j ) ;

140 : if ( c1 != c2 ) break;

141 : a_c++;

142 : }

143 :

.\array_counter.cpp  Sun Mar 14 17:27:06 2021
144 :		if ( a_c == a_f && cnt_replace == 0) {
145 :			// match
146 :			int to = i + a_t;
147 :			for( int k=0; k<a_t; k++ ) {
148 :				*( char_string_2 + i + k + cnt_replace*(a_t- a_f ) ) = 
149 :				  *( to_string + k );
150 :			}
151 :			i += a_f - 1 ;
152 :			cnt_replace++;
153 :		} else {
154 :			*( char_string_2 + i + cnt_replace*(a_t- a_f ) ) = c1;
155 :		}
156 :	}
157 :	*( char_string_2 + count + cnt_replace*( a_t - a_f ) ) = '\0';
158 :	put_memories ( char_string_2 );
159 :
160 :	return char_string_2;
161 :}
162 :

 ---- source code 1 end ----