Macy’s posts smaller-than-expected loss, shares rise