示例#1
0
文件: parse_rx.c 项目: cardamon/lvm2
static int _find_leftmost_common(struct rx_node *or,
                                 struct rx_node **l,
                                 struct rx_node **r,
				 unsigned leftmost)
{
	struct rx_node *left = or->left, *right = or->right;
	unsigned left_depth = _depth(left, leftmost);
	unsigned right_depth = _depth(right, leftmost);

	while (left_depth > right_depth && left->type != OR) {
		left = LEFT(left);
		left_depth--;
	}

	while (right_depth > left_depth && right->type != OR) {
		right = LEFT(right);
		right_depth--;
	}

	if (left_depth != right_depth)
		return 0;

	while (left_depth) {
		if (left->type == CAT && right->type == CAT) {
			if (_nodes_equal(LEFT(left), LEFT(right))) {
				*l = left;
				*r = right;
				return 1;
			}
		}
		if (left->type == OR || right->type == OR)
			break;
		left = LEFT(left);
		right = LEFT(right);
		left_depth--;
	}

	return 0;
}
LogBufferStream::LogBufferStream(outputStream* wst, size_t len) : stringStream(NEW_RESOURCE_ARRAY(char, len), len), _wst(wst) {
}

void LogBufferStream::stamp() {
if(_wst!=NULL){
    TimeStamp* stamp = _wst->get_time_stamp();
    if (!stamp->is_updated()) {
      stamp->update();
    }
    print("%.3f", stamp->seconds());
  } else {
    stringStream::stamp();
  }
}

// ============================================================================
// BufferedLoggerMark implementation
// ============================================================================


BufferedLoggerMark::BufferedLoggerMark(const char* tag, int opt, bool stp, bool crp, outputStream* st, long bufferSize) : LoggerStackObj(tag, opt, stp, crp, st), _mst(st, bufferSize), _depth(0) {
}

void BufferedLoggerMark::vout(const char*format,va_list ap){
  _mst.vprint(format, ap);
}