Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void TraceError(int s, int v)
- {
- int main_buf[2048];
- int buffer_pos; int string_pos; int q;
- for ( ; s[string_pos] != '%'; ++string_pos )
- {
- main_buf[buffer_pos] = s[string_pos];
- }
- //Now, we found an insertion token, so insert it
- //if ( s[string_pos] != '%' ) //copy the buffer text over to the buffer, until we find our token
- //{
- // main_buf[buffer_pos] = s[string_pos];
- // ++buffer_pos;
- //}
- //else //found a special token
- //{
- switch(s[string_pos+1])
- {
- case s:
- {
- ++buffer_pos;
- main_buf[buffer_pos+q+1] = ' '; //add a trailing space
- for ( q = 0; v[q]; ++q ) //until we reach NULL
- {
- main_buf[buffer_pos+q] = v[q]; //copy the string passed as a param
- //over to the buffer
- }
- ++buffer_pos;
- main_buf[buffer_pos+q+1] = ' '; //add a trailing space
- ++buffer_pos; //set up the buffer for the next char
- break;
- }
- case f:
- {
- ++buffer_pos;
- main_buf[buffer_pos+q+1] = ' '; //add a trailing space
- int i_val[12];
- ftoa(i_val,v);
- for ( q = 0; i_val[q]; ++q )
- {
- main_buf[buffer_pos+q] = i_val[q];
- }
- main_buf[buffer_pos+q+1] = ' '; //add a trailing space
- ++buffer_pos; //set up the buffer for the next char
- break;
- }
- case d:
- {
- ++buffer_pos;
- main_buf[buffer_pos+q+1] = ' '; //add a trailing space
- int f_val[12];
- itoa(f_val,v);
- for ( q = 0; f_val[q] ; ++q )
- {
- main_buf[buffer_pos+q] = f_val[q];
- }
- main_buf[buffer_pos+q+1] = ' '; //add a trailing space
- ++buffer_pos; //set up the buffer for the next char
- break;
- }
- default: ++buffer_pos; break;
- }
- //we copied the insertion, so, resume the rest o the string:
- for ( ; s[string_pos]; ++string_pos ) //Until we reach NULL
- {
- //copy the rest of the string:
- main_buf[buffer_pos] = s[string_pos];
- }
- TraceS(main_buf); TraceNL();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement