コード例 #1
0
ファイル: line.c プロジェクト: JohnTimothyDaly/less-fork
static int
store_tab(int attr, off_t pos)
{
	int to_tab = column + cshift - lmargin;
	int i;

	if (ntabstops < 2 || to_tab >= tabstops[ntabstops-1])
		to_tab = tabdefault -
		    ((to_tab - tabstops[ntabstops-1]) % tabdefault);
	else {
		for (i = ntabstops - 2;  i >= 0;  i--)
			if (to_tab >= tabstops[i])
				break;
		to_tab = tabstops[i+1] - to_tab;
	}

	if (column + to_tab - 1 + pwidth(' ', attr, 0) +
	    attr_ewidth(attr) > sc_width)
		return (1);

	do {
		STORE_CHAR(' ', attr, " ", pos);
	} while (--to_tab > 0);
	return (0);
}
コード例 #2
0
ファイル: line.c プロジェクト: JohnTimothyDaly/less-fork
static int
store_prchar(char c, off_t pos)
{
	char *s;

	/*
	 * Convert to printable representation.
	 */
	s = prchar(c);

	/*
	 * Make sure we can get the entire representation
	 * of the character on this line.
	 */
	if (column + (int)strlen(s) - 1 +
	    pwidth(' ', binattr, 0) + attr_ewidth(binattr) > sc_width)
		return (1);

	for (; *s != 0; s++) {
		STORE_CHAR(*s, AT_BINARY, NULL, pos);
	}
	return (0);
}
コード例 #3
0
ファイル: imexporter.c プロジェクト: Zauberstuhl/aqbanking
int AB_ImExporterAccountInfo_toDb(const AB_IMEXPORTER_ACCOUNTINFO *iea,
				  GWEN_DB_NODE *db){
  assert(iea);

#define STORE_CHAR(NAME) \
  if (iea->NAME) \
    GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, \
                         __STRING(NAME), iea->NAME)
#define STORE_INT(NAME) \
  GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, \
                      __STRING(NAME), iea->NAME)
  STORE_CHAR(bankCode);
  STORE_CHAR(bankName);
  STORE_CHAR(accountNumber);
  STORE_CHAR(accountName);
  STORE_CHAR(iban);
  STORE_CHAR(bic);
  STORE_CHAR(owner);
  STORE_CHAR(currency);
  STORE_CHAR(description);
  STORE_INT(accountType);
  STORE_INT(accountId);
#undef STORE_CHAR
#undef STORE_INT

  if (iea->accStatusList) {
    AB_ACCOUNT_STATUS *ast;

    ast=AB_AccountStatus_List_First(iea->accStatusList);
    if (ast) {
      GWEN_DB_NODE *dbG;

      dbG=GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_OVERWRITE_GROUPS,
			   "statusList");
      assert(dbG);

      while(ast) {
	GWEN_DB_NODE *dbT;

	dbT=GWEN_DB_GetGroup(dbG, GWEN_PATH_FLAGS_CREATE_GROUP,
			     "status");
	assert(dbT);
	if (AB_AccountStatus_toDb(ast, dbT))
	  return -1;

	ast=AB_AccountStatus_List_Next(ast);
      }
    }
  }

  if (iea->transactions) {
    AB_TRANSACTION *t;

    t=AB_Transaction_List_First(iea->transactions);
    if (t) {
      GWEN_DB_NODE *dbG;

      dbG=GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_OVERWRITE_GROUPS,
			   "transactionList");
      assert(dbG);

      while(t) {
	GWEN_DB_NODE *dbT;

	dbT=GWEN_DB_GetGroup(dbG, GWEN_PATH_FLAGS_CREATE_GROUP,
			     "transaction");
	assert(dbT);
	if (AB_Transaction_toDb(t, dbT))
	  return -1;
	t=AB_Transaction_List_Next(t);
      }
    }
  }

  if (iea->standingOrders) {
    AB_TRANSACTION *t;

    t=AB_Transaction_List_First(iea->standingOrders);
    if (t) {
      GWEN_DB_NODE *dbG;

      dbG=GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_OVERWRITE_GROUPS,
			   "standingOrderList");
      assert(dbG);

      while(t) {
	GWEN_DB_NODE *dbT;

	dbT=GWEN_DB_GetGroup(dbG, GWEN_PATH_FLAGS_CREATE_GROUP,
			     "standingOrder");
	assert(dbT);
	if (AB_Transaction_toDb(t, dbT))
	  return -1;
	t=AB_Transaction_List_Next(t);
      }
    }
  }

  if (iea->transfers) {
    AB_TRANSACTION *t;

    t=AB_Transaction_List_First(iea->transfers);
    if (t) {
      GWEN_DB_NODE *dbG;

      dbG=GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_OVERWRITE_GROUPS,
			   "transferList");
      assert(dbG);

      while(t) {
	GWEN_DB_NODE *dbT;

	dbT=GWEN_DB_GetGroup(dbG, GWEN_PATH_FLAGS_CREATE_GROUP,
			     "transfer");
	assert(dbT);
	if (AB_Transaction_toDb(t, dbT))
	  return -1;
	t=AB_Transaction_List_Next(t);
      }
    }
  }

  if (iea->datedTransfers) {
    AB_TRANSACTION *t;

    t=AB_Transaction_List_First(iea->datedTransfers);
    if (t) {
      GWEN_DB_NODE *dbG;

      dbG=GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_OVERWRITE_GROUPS,
			   "datedTransferList");
      assert(dbG);

      while(t) {
	GWEN_DB_NODE *dbT;

	dbT=GWEN_DB_GetGroup(dbG, GWEN_PATH_FLAGS_CREATE_GROUP,
			     "datedTransfer");
	assert(dbT);
	if (AB_Transaction_toDb(t, dbT))
	  return -1;
	t=AB_Transaction_List_Next(t);
      }
    }
  }

  if (iea->notedTransactions) {
    AB_TRANSACTION *t;

    t=AB_Transaction_List_First(iea->notedTransactions);
    if (t) {
      GWEN_DB_NODE *dbG;

      dbG=GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_OVERWRITE_GROUPS,
			   "notedTransactionList");
      assert(dbG);

      while(t) {
	GWEN_DB_NODE *dbT;

	dbT=GWEN_DB_GetGroup(dbG, GWEN_PATH_FLAGS_CREATE_GROUP,
			     "notedTransaction");
	assert(dbT);
	if (AB_Transaction_toDb(t, dbT))
	  return -1;
	t=AB_Transaction_List_Next(t);
      }
    }
  }

  return 0;
}
コード例 #4
0
ファイル: line.c プロジェクト: JohnTimothyDaly/less-fork
static int
do_append(LWCHAR ch, char *rep, off_t pos)
{
	int a;
	LWCHAR prev_ch;

	a = AT_NORMAL;

	if (ch == '\b') {
		if (bs_mode == BS_CONTROL)
			goto do_control_char;

		/*
		 * A better test is needed here so we don't
		 * backspace over part of the printed
		 * representation of a binary character.
		 */
		if (curr <= lmargin ||
		    column <= lmargin ||
		    (attr[curr - 1] & (AT_ANSI|AT_BINARY))) {
			STORE_PRCHAR('\b', pos);
		} else if (bs_mode == BS_NORMAL) {
			STORE_CHAR(ch, AT_NORMAL, NULL, pos);
		} else if (bs_mode == BS_SPECIAL) {
			overstrike = backc();
		}

		return (0);
	}

	if (overstrike > 0) {
		/*
		 * Overstrike the character at the current position
		 * in the line buffer.  This will cause either
		 * underline (if a "_" is overstruck),
		 * bold (if an identical character is overstruck),
		 * or just deletion of the character in the buffer.
		 */
		overstrike = utf_mode ? -1 : 0;
		/* To be correct, this must be a base character.  */
		prev_ch = get_wchar(linebuf + curr);
		a = attr[curr];
		if (ch == prev_ch) {
			/*
			 * Overstriking a char with itself means make it bold.
			 * But overstriking an underscore with itself is
			 * ambiguous.  It could mean make it bold, or
			 * it could mean make it underlined.
			 * Use the previous overstrike to resolve it.
			 */
			if (ch == '_') {
				if ((a & (AT_BOLD|AT_UNDERLINE)) != AT_NORMAL)
					a |= (AT_BOLD|AT_UNDERLINE);
				else if (last_overstrike != AT_NORMAL)
					a |= last_overstrike;
				else
					a |= AT_BOLD;
			} else {
				a |= AT_BOLD;
			}
		} else if (ch == '_') {
			a |= AT_UNDERLINE;
			ch = prev_ch;
			rep = linebuf + curr;
		} else if (prev_ch == '_') {
			a |= AT_UNDERLINE;
		}
		/* Else we replace prev_ch, but we keep its attributes.  */
	} else if (overstrike < 0) {
		if (is_composing_char(ch) ||
		    is_combining_char(get_wchar(linebuf + curr), ch))
			/* Continuation of the same overstrike.  */
			a = last_overstrike;
		else
			overstrike = 0;
	}

	if (ch == '\t') {
		/*
		 * Expand a tab into spaces.
		 */
		switch (bs_mode) {
		case BS_CONTROL:
			goto do_control_char;
		case BS_NORMAL:
		case BS_SPECIAL:
			STORE_TAB(a, pos);
			break;
		}
	} else if ((!utf_mode || is_ascii_char(ch)) && control_char((char)ch)) {
do_control_char:
		if (ctldisp == OPT_ON ||
		    (ctldisp == OPT_ONPLUS && IS_CSI_START(ch))) {
			/*
			 * Output as a normal character.
			 */
			STORE_CHAR(ch, AT_NORMAL, rep, pos);
		} else {
			STORE_PRCHAR((char)ch, pos);
		}
	} else if (utf_mode && ctldisp != OPT_ON && is_ubin_char(ch)) {
		char *s;

		s = prutfchar(ch);

		if (column + (int)strlen(s) - 1 +
		    pwidth(' ', binattr, 0) + attr_ewidth(binattr) > sc_width)
			return (1);

		for (; *s != 0; s++)
			STORE_CHAR(*s, AT_BINARY, NULL, pos);
	} else {
		STORE_CHAR(ch, a, rep, pos);
	}
	return (0);
}