Example #1
0
int tool::source::Column::Check()
{
	if (m_read.Open())
	{
		int character = 0;
		std::size_t column = 1;
		std::string string_line = "";
		while (!m_read.IsEOF())
		{
			character = m_read.GetCharacter();
			if (IsNewLine(character))
			{
				Newline(column, string_line);
				column = 1;
				string_line.clear();
			}
			else if (IsSkip(character))
			{
				continue;
			}
			else if (std::isspace(character))
			{
				if (character == ' ')
				{
					++column;
					string_line.push_back(character);
				}
				else if (character == '\t')
				{
					column += (4 - ((column - 1) % 4));
					string_line.push_back(character);
				}
			}
			else
			{
				++column;
				if (string_line.size() < 
					MAXIMUM_STRING_COLUMN_BUFFER_SIZE + 1)
				{
					string_line.push_back(character);
				}
				else if (string_line.size() == 
					MAXIMUM_STRING_COLUMN_BUFFER_SIZE + 1)
				{
					string_line += "...";
				}
			}
		}
		if (!string_line.empty())
		{
			Newline(column - 1, string_line);
		}
		return 0;
	}
	return 1;
}
Example #2
0
static int Putchar(char c){
	switch(c){
	case '\n': Newline(); return;
	case '\t': NextTabStop(); return;
	}

	CHAR(row,column) = c;	
	COLOR(row,column) = 0x07;
	if(column++ > WIDTH){
		Newline();
	}
}
Example #3
0
static void print_probs(FILE *f, vp9_coeff_accum *context_counters,
                        int block_types, const char *header) {
  int type, ref, band, pt, t;

  fprintf(f, "static const vp9_coeff_probs %s = {", header);

  type = 0;
#define Newline(x, spaces) (x ? " " : "\n" spaces)
  do {
    fprintf(f, "%s%s{ /* block Type %d */",
            Comma(type), Newline(type, "  "), type);
    ref = 0;
    do {
      fprintf(f, "%s%s{ /* %s */",
              Comma(band), Newline(band, "    "), ref ? "Inter" : "Intra");
      band = 0;
      do {
        fprintf(f, "%s%s{ /* Coeff Band %d */",
                Comma(band), Newline(band, "      "), band);
        pt = 0;
        do {
          unsigned int branch_ct[ENTROPY_NODES][2];
          unsigned int coef_counts[MAX_ENTROPY_TOKENS + 1];
          vp9_prob coef_probs[ENTROPY_NODES];

          if (pt >= 3 && band == 0)
            break;
          for (t = 0; t < MAX_ENTROPY_TOKENS + 1; ++t)
            coef_counts[t] = context_counters[type][ref][band][pt][t];
          vp9_tree_probs_from_distribution(vp9_coef_tree, coef_probs,
                                           branch_ct, coef_counts, 0);
          branch_ct[0][1] = coef_counts[MAX_ENTROPY_TOKENS] - branch_ct[0][0];
          coef_probs[0] = get_binary_prob(branch_ct[0][0], branch_ct[0][1]);
          fprintf(f, "%s\n      {", Comma(pt));

          t = 0;
          do {
            fprintf(f, "%s %3d", Comma(t), coef_probs[t]);
          } while (++t < ENTROPY_NODES);

          fprintf(f, " }");
        } while (++pt < PREV_COEF_CONTEXTS);
        fprintf(f, "\n      }");
      } while (++band < COEF_BANDS);
      fprintf(f, "\n    }");
    } while (++ref < REF_TYPES);
    fprintf(f, "\n  }");
  } while (++type < block_types);
  fprintf(f, "\n};\n");
}
Example #4
0
void KTextPipe::Format(const TCHAR * pattern, const void * vdata, const DicItem * dic)
{
	if ( pattern == NULL )
		return;

	while ( * pattern )
	{
		switch ( * pattern )
		{
			case '\n':	
				Newline();		
				break;

			case '#' :
				pattern ++;
				vdata = Pound( * pattern, (const long *) vdata, dic);
				break;

			case '%' : 
				pattern ++;
				
				vdata = Percent( * pattern, (const long *) vdata, dic);
				break;

			default  :
				Put(* pattern);
		}

		pattern ++;
	}
}
Example #5
0
/*
 * Put one character to the screen using the current cursor position
 * and attribute, scrolling if needed.  The caller should update
 * the cursor position once all characters have been written.
 */
static void Output_Literal_Character(int c) {
    int numSpaces;

    switch (c) {
        case '\n':
            Clear_To_EOL();
            Newline();
            break;

        case '\t':
            numSpaces = TABWIDTH - (s_cons.col % TABWIDTH);
            while (numSpaces-- > 0)
                Put_Graphic_Char(' ');
            break;

        default:
            Put_Graphic_Char(c);
            break;
    }

#ifndef NDEBUG
    /*
     * When compiled with --enable-port-e9-hack, Bochs will send writes
     * to port E9 to the console.  This helps tremendously with debugging,
     * because it allows debug Print() statements to be visible after
     * Bochs has exited.
     */
    Out_Byte(0xE9, c);
#endif
}
Example #6
0
void Serialize( FILE* fp, const B& b )
{
	Write( fp, b.a );
	Write( fp, b.b );
	Write( fp, b.c );
	Newline( fp );
}
Example #7
0
void IRCTextCtrl::preAddMessage()
{
	SetInsertionPointEnd();

	if(GetLastPosition() > 0)
		Newline();
}
Example #8
0
WORD	RefreshRegisters(WORD maxLines, BOOL fullRefresh) {
	WORD	count = 0;

    if(CurDisplay->ds_RegFlag) {

	RefreshRegister("D0", programD0, lastD0);
	RefreshRegister("D1", programD1, lastD1);
	RefreshRegister("D2", programD2, lastD2);
	RefreshRegister("D3", programD3, lastD3);
	count++; 
	Newline(); 
	maxLines--; 
	if (!maxLines) return count;

	RefreshRegister("D4", programD4, lastD4);
	RefreshRegister("D5", programD5, lastD5);
	RefreshRegister("D6", programD6, lastD6);
	RefreshRegister("D7", programD7, lastD7);
	count++; Newline(); maxLines--; if (!maxLines) return count;

	RefreshRegister("A0", programA0, lastA0);
	RefreshRegister("A1", programA1, lastA1);
	RefreshRegister("A2", programA2, lastA2);
	RefreshRegister("A3", programA3, lastA3);
	count++; Newline(); maxLines--; if (!maxLines) return count;

	RefreshRegister("A4", programA4, lastA4);
	RefreshRegister("A5", programA5, lastA5);
	RefreshRegister("A6", programA6, lastA6);
	RefreshRegister("A7", programA7, lastA7);
	count++; Newline(); maxLines--; if (!maxLines) return count;

	RefreshRegister("PC", programPC, lastPC);
	ScrPlain();
	ScrPrintf("SR: ");
	if (programSR != lastSR)ScrHighlight();
	ScrPrintf("$%04X ", programSR);
	DisplayFlags();
	ScrPlain();
	ScrPrintf("STATE: ");
	if (programState != lastState)
	    ScrHighlight();
	ScrPrintf("%s", StateText(programState));
	count++; Newline(); maxLines--; if (!maxLines) return count;
    }
    return count;
}
Example #9
0
BOOL ShowWatchTitle(BOOL fullRefresh, WORD *count, WORD *maxLines) 
{
    if(fullRefresh != -1) {
	if(CurDisplay->ds_RegFlag) {
	    Newline(); 
            (*count)++;
	    (*maxLines)++;
	}
    }

    ScrPlain();
    ScrInverse();
    ScrPuts("WATCHPOINT               ADDRESS   CONTENTS");
//  	     xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx  xx
    Newline(); 
    (*count)++;
    (*maxLines)++;

    return TRUE;
}
Example #10
0
/*
 * Write the graphic representation of given character to the screen
 * at current position, with current attribute, scrolling if
 * necessary.
 */
static void Put_Graphic_Char(int c) {
    uchar_t *v = VIDMEM + s_cons.row * (NUMCOLS * 2) + s_cons.col * 2;

    /* Put character at current position */
    *v++ = (uchar_t) c;
    *v = s_cons.currentAttr;

    if(s_cons.col < NUMCOLS - 1)
        ++s_cons.col;
    else
        Newline();
}
Example #11
0
//! ************************************************************************************************
//!
//! ************************************************************************************************
void rdmp::SignalsHelloWorld()
{
    boost::signals2::signal<void()> sigHellWorld;
    sigHellWorld.connect(HellWorld());
    sigHellWorld();

    boost::signals2::signal<void()> sigWooHoo;
    sigWooHoo.connect(Woo());
    sigWooHoo.connect(Hoo());
    sigWooHoo.connect(Newline());
    sigWooHoo();

    // slots are invoked this order:
    // 1) ungrouped slots connected with boost::signals2::at_front
    // 2) grouped slots according to ordering of their groups
    // 3) ungrouped slots connected with boost::signals2::at_back
    boost::signals2::signal<void()> sigHooWoo;
    sigHooWoo.connect(1, Woo());
    sigHooWoo.connect(0, Hoo());
    sigHooWoo.connect(2, Newline());
    sigHooWoo();
}
void TextTerminal::PutChar(TextBuffer* textbuf, char c)
{
	if ( ansimode )
		return PutAnsiEscaped(textbuf, c);

	if ( mbsinit(&ps) )
	{
		switch ( c )
		{
		case '\n': Newline(textbuf); return;
		case '\r': column = 0; return;
		case '\b': Backspace(textbuf); return;
		case '\t': Tab(textbuf); return;
		case '\e': AnsiReset(); return;
		case 127: return;
		default: break;
		}
	}

	wchar_t wc;
	size_t result = mbrtowc(&wc, &c, 1, &ps);
	if ( result == (size_t) -2 )
		return;
	if ( result == (size_t) -1 )
	{
		memset(&ps, 0, sizeof(ps));
		wc = L'�';
	}
	if ( result == (size_t) 0 )
		wc = L' ';

	if ( textbuf->Width() <= column )
		Newline(textbuf);
	TextPos pos(column++, line);
	TextChar tc(wc, vgacolor, ATTR_CHAR | next_attr);
	textbuf->SetChar(pos, tc);
	next_attr = 0;
}
void TextTerminal::Tab(TextBuffer* textbuf)
{
	if ( column == textbuf->Width() )
		Newline(textbuf);
	unsigned int count = 8 - (column % 8);
	for ( unsigned int i = 0; i < count; i++ )
	{
		if ( column == textbuf->Width() )
			break;
		TextPos pos(column++, line);
		TextChar tc(' ', vgacolor, i == 0 ? ATTR_CHAR : 0);
		textbuf->SetChar(pos, tc);
	}
}
Example #14
0
// parses the next token
// returns false if done
void opScanner::ScanTokens(const inputtype& Input) {
    // if we've reached the end of the Input stream,
    // add an EOF token and return false

    int size = Input.Size();
    int current = 0;

    // TODO: the input list of chars is really a bad idea
    //		Input should be a vector, and we should not alter it,
    //		instead we should iterate over it (maybe w/ an iterator we pass
    //		around.

    while (current != size) {
        // scan for the next token
        // (with the correct precedence)
        if (current != size && Newline(Input, current))
            ;
        else if (current != size && CComment(Input, current))
            ;
        else if (current != size && Comment(Input, current))
            ;
        else if (current != size && String(Input, current))
            ;
        else if (current != size && WhiteSpace(Input, current))
            ;
        else if (current != size && Operator(Input, current))
            ;
        else if (current != size && Hexadecimals(Input, current))
            ;
        else if (current != size && Number(Input, current))
            ;
        else if (current != size && GetId(Input, current))
            ;
        else if (current != size) {
            opToken newToken(T_ANYCHAR, Input[current], CurrentLine);

            Tokens.PushBack(newToken);
            ++current;
        }
    }

    Tokens.PushBack(opToken(T_EOF, "", CurrentLine));
}
Example #15
0
void KTextPipe::WriteArray(const void * Array, long count, long elmsize, bool decimal)
{
	if ( ! m_bOpened )
		return;

	assert(Array);

	const char  * bArray = (const char *)  Array;
	const short * sArray = (const short *) Array;
	const long  * lArray = (const long *)  Array;
	const RECT  * rArray = (const RECT *)  Array;
	
	Put('{'); Put(' ');
	for (long i=0; i<count; i++)
	{
		if ( i )
		{
			Put(','); 
			
			if ( m_linelen > 78 )
				Newline();
			else
				Put(' ');
		}

		switch ( elmsize )
		{
			case 1:  
				if (decimal) 
					WriteDec((long) bArray[i]); 
				else 
					WriteHex(bArray[i] & 0xFF); 
				break;
			
			case 2:  
				if (decimal) 
					WriteDec((long) sArray[i]); 
				else 
					WriteHex(sArray[i] & 0xFFFF); 
				break;

			case 4:  
				if (decimal) 
					WriteDec(lArray[i]); 
				else 
					WriteHex(lArray[i]); 
				break;

			case sizeof(RECT):
				Write("{ "); WriteDec(rArray[i].left);
				Put(',');    WriteDec(rArray[i].top);
				Put(',');    WriteDec(rArray[i].right);
				Put(',');    WriteDec(rArray[i].bottom);
				Write(" }");
				break;

			default: assert(FALSE);
		}

	}

	Put(' '); Put('}');
}
Example #16
0
WORD	RefreshWatchpoints(WORD maxLines, BOOL fullRefresh) {
	WORD	count = 0;
	WORD	i, undef;
	ULONG	val;
	BOOL	flag = FALSE;


	for (i=0; i<MAXWP && maxLines > 0; i++) {
		switch (wpTable[i].type) {
			case WP_UNSET:		
				break;
			case WP_BYTES:
				val = ParseExp(wpTable[i].expression, &undef, strlen(wpTable[i].expression));
				if (undef)
					ScrPrintf("%-24.24s *UNDEFINED*", wpTable[i].expression);
				else {
					WORD	j = (CurDisplay->ds_ScrCols-35)/3;
					UBYTE	*ps = (UBYTE *)val;

					if (!flag) {
					    flag = ShowWatchTitle(fullRefresh,&count,&maxLines);
					}

					ScrPrintf("%-24.24s %08X  ", wpTable[i].expression, val);
					while (j > 0) {
						ScrPrintf("%02X ", *ps++);
						--j;
					}
				}
				count++; 
				Newline(); 
				maxLines--;

				break;
			case WP_WORDS:
				val = ParseExp(wpTable[i].expression, &undef, strlen(wpTable[i].expression));
				if (undef)
					ScrPrintf("%-24.24s *UNDEFINED*", wpTable[i].expression);
				else {
					WORD	j = (CurDisplay->ds_ScrCols-35)/5;
					UWORD	*ps = (UWORD *)val;

					if (!flag) {
					    flag = ShowWatchTitle(fullRefresh,&count,&maxLines);
					}
					ScrPrintf("%-24.24s %08X  ", wpTable[i].expression, val);
					while (j > 0) {
						ScrPrintf("%04X ", *ps++);
						--j;
					}
				}
				count++; Newline(); maxLines--;
				break;
			case WP_LONGS:
				val = ParseExp(wpTable[i].expression, &undef, strlen(wpTable[i].expression));
				if (undef)
					ScrPrintf("%-24.24s *UNDEFINED*", wpTable[i].expression);
				else {
					WORD	j = (CurDisplay->ds_ScrCols-35)/9;
					ULONG	*ps = (ULONG *)val;

					if (!flag) {
					    flag = ShowWatchTitle(fullRefresh,&count,&maxLines);
					}
					ScrPrintf("%-24.24s %08X  ", wpTable[i].expression, val);
					while (j > 0) {
						ScrPrintf("%08X ", *ps++);
						--j;
					}
				}
				count++; 
				Newline(); 
				maxLines--;
				break;
		}
	}

	// add a newline to end if at top of screen
	if(flag && !CurDisplay->ds_RegFlag) {
	    Newline(); 
            count++;
	    maxLines++;
	}

	return count;
}
Example #17
0
static void NextTabStop(){
	column += TABSTOP - (column%TABSTOP);
	if(column > WIDTH)
		Newline();
}
Example #18
0
int
ParseInput(register DviWidget dw)
{
	int		n, k;
	int		c;
	char		Buffer[BUFSIZ];
	int		NextPage;
	int		otherc;

	StopSeen = 0;

	/*
	 * make sure some state exists
	 */

	if (!dw->dvi.state)
	    push_env (dw);
	for (;;) {
		switch (DviGetC(dw, &c)) {
		case '\n':	
			break;
		case ' ':	/* when input is text */
		case 0:		/* occasional noise creeps in */
			break;
		case '{':	/* push down current environment */
			push_env(dw);
			break;
		case '}':
			pop_env(dw);
			break;
		/*
		 * two motion digits plus a character
		 */
		case '0': case '1': case '2': case '3': case '4':
		case '5': case '6': case '7': case '8': case '9':
			HorizontalMove(dw, (c-'0')*10 +
					   DviGetC(dw,&otherc)-'0');
			/* fall through */
		case 'c':	/* single ascii character */
			DviGetC(dw,&c);
		    	if (c == ' ')
			    break;
			Buffer[0] = c;
			Buffer[1] = '\0';
			(void) PutCharacter (dw, Buffer);
			break;
		case 'C':
			GetWord (dw, Buffer, BUFSIZ);
			(void) PutCharacter (dw, Buffer);
			break;
		case 't':
			Buffer[1] = '\0';
			while (DviGetC (dw, &c) != EOF
			       && c != ' ' && c != '\n') {
				Buffer[0] = c;
				HorizontalMove (dw, PutCharacter (dw, Buffer));
			}
			break;
		case 'u':
			n = GetNumber(dw);
			Buffer[1] = '\0';
			while (DviGetC (dw, &c) == ' ')
				;
			while (c != EOF && c != ' ' && c != '\n') {
				Buffer[0] = c;
				HorizontalMove (dw,
						PutCharacter (dw, Buffer) + n);
				DviGetC (dw, &c);
			}
			break;

		case 'D':	/* draw function */
			(void) GetLine(dw, Buffer, BUFSIZ);
			if (dw->dvi.display_enable)
				ParseDrawFunction(dw, Buffer);
			break;
		case 's':	/* ignore fractional sizes */
			n = GetNumber(dw);
			dw->dvi.state->font_size = n;
			break;
		case 'f':
			n = GetNumber(dw);
			dw->dvi.state->font_number = n;
			break;
		case 'H':	/* absolute horizontal motion */
			k = GetNumber(dw);
			HorizontalGoto(dw, k);
			break;
		case 'h':	/* relative horizontal motion */
			k = GetNumber(dw);
			HorizontalMove(dw, k);
			break;
		case 'w':	/* word space */
			Word (dw);
			break;
		case 'V':
			n = GetNumber(dw);
			VerticalGoto(dw, n);
			break;
		case 'v':
			n = GetNumber(dw);
			VerticalMove(dw, n);
			break;
		case 'P':	/* new spread */
			break;
		case 'p':	/* new page */
			(void) GetNumber(dw);
			NextPage = dw->dvi.current_page + 1;
			RememberPagePosition(dw, NextPage);
			FlushCharCache (dw);
			return(NextPage);
		case 'N':
			n = GetNumber(dw);
			PutNumberedCharacter (dw, n);
			break;
		case 'n':	/* end of line */
			GetNumber(dw);
			GetNumber(dw);
			Newline (dw);
			HorizontalGoto(dw, 0);
			break;
		case 'F':       /* input files */
		case '+':	/* continuation of X device control */
		case 'm':	/* color */
		case '#':	/* comment */
			GetLine(dw, NULL, 0);
			break;
		case 'x':	/* device control */
			ParseDeviceControl(dw);
			break;
		case EOF:
			dw->dvi.last_page = dw->dvi.current_page;
			FlushCharCache (dw);
			return dw->dvi.current_page;
		default:
			break;
		}
	}
}
Example #19
0
void Serialize( FILE* fp, const C& c )
{
	Write( fp, c.a );
	Serialize( fp, c.b );
	Newline( fp );
}
Example #20
0
void Serialize( FILE* fp, const A& a )
{
	Write( fp, a.a );
	Write( fp, a.b );
	Newline( fp );
}