Stocks wavered between small gains and losses on Thursday to close little changed as traders weighed generally strong earnings reports against the falling fortunes of energy companies.