Court bars ex-army chief from contesting Pakistan polls